[Code Jam 2022 Qualification Round 2022] d1000000

d1000000

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
#include <bits/stdc++.h>
using namespace std;

int solve(vector<int>& d) {
sort(d.begin(), d.end());
int res = 1;
for(auto& n : d) {
if(n >= res)
res++;
}
return res - 1;
}

int main() {
int tc;
cin>>tc;
for(int i = 1; i <= tc; i++) {
int n;
cin>>n;
vector<int> d(n);
for(int i = 0; i < n;i++) cin>>d[i];
cout<<"Case #"<<i<<": "<<solve(d)<<endl;
}
return 0;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2022/04/02/PS/Google/d1000000/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.