DuongNhi99

GARDENING

Dec 10th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. const int N = 1e5 + 5;
  6.  
  7. int n;
  8. ll a[N];
  9.  
  10. int main() {
  11.     //freopen("in.txt", "r", stdin);
  12.     freopen("GARDENING.inp", "r", stdin);
  13.     freopen("GARDENING.out", "w", stdout);
  14.     ios_base::sync_with_stdio(false);
  15.     cin.tie(NULL); cout.tie(NULL);
  16.  
  17.     cin >> n;
  18.     for(int i = 0; i < n; ++i)
  19.         cin >> a[i];
  20.  
  21.     sort(a, a + n, greater<int>());
  22.     ll ans = 0;
  23.     for(int i = 0; i < n; ++i)
  24.         ans = max(ans, a[i]+i);
  25.  
  26.     cout << ans;
  27.  
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment