Advertisement
Saleh127

Light OJ 1148

Sep 13th, 2021
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10.  
  11. test
  12. {
  13. ll n,m,i,j,k,l=0;
  14.  
  15. cin>>n;
  16.  
  17. map<ll,ll>x;
  18.  
  19. for(i=0;i<n;i++)
  20. {
  21. cin>>m;
  22. x[m]++;
  23. }
  24.  
  25. for(auto d:x)
  26. {
  27. k=d.second/(d.first+1);
  28. if(d.second%(d.first+1)) k++;
  29. l+=(k*(d.first+1));
  30. }
  31.  
  32. cout<<"Case "<<cs<<": "<<l<<endl;
  33. }
  34.  
  35. return 0;
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement