-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLightOj 1148.cpp
67 lines (49 loc) · 1.19 KB
/
LightOj 1148.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* Which of the favors of your Lord will you deny? */
#include<bits/stdc++.h>
using namespace std;
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define SULL(n) scanf("%llu",&n)
#define SC(n) scanf("%c",&n)
#define SD(n) scanf("%lf",&n)
#define fr(i,a,b) for(int i=a ,_b=(b) ;i<= _b;i++)
#define LL long long
#define PUB push_back
#define POB pop_back
#define MP make_pair;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define mset(x,v) memset(x,v,sizeof(x))
#define GCD __gcd
#define DEBUG cout<<"aw"<<endl;
int cnt[1000010];
int main()
{
int tc;
SI(tc);
fr(i,1,tc)
{
fill(cnt,cnt+1000000,0);
int n, hi=-1;
SI(n);
fr(j,1,n)
{
int num;
SI(num);
cnt[num]++;
if(num>hi)
hi=num;
}
LL ans=0;
fr(j,0,hi)
{
if(cnt[j]>0)
{
//cout<<j<<" ** "<<cnt[j]<<" "<<((cnt[j]+j)/(j+1))*(j+1)<<endl;
ans = ans + ((cnt[j]+j)/(j+1))*(j+1); // ceil[(cnt[j]/(j+1))]
}
}
printf("Case %d: %lld\n",i,ans);
}
return 0;
}