Created
October 5, 2019 16:09
-
-
Save surinoel/b0fa4fe6a069a83fcf1c8d0ee37ff14d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
#include <functional> | |
using namespace std; | |
int main(void) { | |
ios_base::sync_with_stdio(false); | |
cin.tie(nullptr); | |
int n; | |
cin >> n; | |
vector<int> v(n); | |
for (int i = 0; i < n; i++) { | |
cin >> v[i]; | |
} | |
sort(v.begin(), v.end(), greater<int>()); | |
int maxv = v[0] + 1; | |
int ans = 1; | |
for (int i = 1; i < v.size(); i++) { | |
if (maxv > v[i] + n) { | |
break; | |
} | |
maxv = max(maxv, v[i] + i + 1); | |
ans += 1; | |
} | |
cout << ans << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment