Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- const int N = 1e5 + 5;
- int n;
- ll a[N];
- int main() {
- //freopen("in.txt", "r", stdin);
- freopen("GARDENING.inp", "r", stdin);
- freopen("GARDENING.out", "w", stdout);
- ios_base::sync_with_stdio(false);
- cin.tie(NULL); cout.tie(NULL);
- cin >> n;
- for(int i = 0; i < n; ++i)
- cin >> a[i];
- sort(a, a + n, greater<int>());
- ll ans = 0;
- for(int i = 0; i < n; ++i)
- ans = max(ans, a[i]+i);
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment