Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <vector>
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <functional>
  5.  
  6. using namespace std;
  7.  
  8. int main(void) {
  9. ios_base::sync_with_stdio(false);
  10. cin.tie(nullptr);
  11.  
  12. int n;
  13. cin >> n;
  14. vector<int> v(n);
  15. for (int i = 0; i < n; i++) {
  16. cin >> v[i];
  17. }
  18.  
  19. sort(v.begin(), v.end(), greater<int>());
  20. int maxv = v[0] + 1;
  21. int ans = 1;
  22. for (int i = 1; i < v.size(); i++) {
  23. if (maxv > v[i] + n) {
  24. break;
  25. }
  26. maxv = max(maxv, v[i] + i + 1);
  27. ans += 1;
  28. }
  29.  
  30. cout << ans << '\n';
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement