-
Notifications
You must be signed in to change notification settings - Fork 0
/
loj1148.cpp
44 lines (36 loc) · 1003 Bytes
/
loj1148.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
using namespace std;
#include<cstdio>
#include<map>
int main()
{
int t,n,i,ans,Case=1;
long x;
scanf("%d",&t);
while(t--)
{
ans=0;
scanf("%d",&n);
map<long,int>m;
for(i=0;i<n;i++)
{
scanf("%ld",&x);
if(m[x]==0)
{
ans+=(x+1);
m[x]++;
}
else
{
if(m[x]>=x+1)
{
ans+=(x+1);
m[x]=1;
}
else
m[x]++;
}
}
printf("Case %d: %d\n",Case++,ans);
}
return 0;
}