- #include <bits/stdc++.h>
- using namespace std;
- int a[1000006];
- int main(){
- int ts;
- scanf("%d", &ts);
- for(int p = 1; p <=ts; p++){
- //memset(a, 0, sizeof(a));
- int n;
- scanf("%d", &n);
- for(int i = 0; i <n; i++){
- int b;
- scanf("%d", &b);
- a[b]++;
- }
- int sum = 0;
- for(int i = 0; i <1000005; i++){
- sum+= (a[i]/(i+1)) * (i+1);
- if(a[i]%(i+1)) sum+= i+1;
- a[i] = 0;
- }
- printf("Case %d: %d\n", p, sum);
- }
- return 0;
- }
Friday, 28 July 2017
Lightoj 1148 - Mad Counting
Subscribe to:
Post Comments (Atom)
Most Featured Post
Lightoj 1159 - Batman
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
-
http://lightoj.com/volume_showproblem.php?problem=1382 Problem analysis: This is a rare problem i wrote about so far. After much strugg...
-
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
No comments:
Post a Comment