Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Created by Никита on 11.10.17.
- // Copyright © 2017 Никита. All rights reserved.
- //
- #include <iostream>
- using namespace std;
- int main(int argc, const char * argv[])
- {
- int i, n, x;
- int a[100000];
- x = 0;
- cin >> n;
- for (i=0; i<n; i++)
- {
- cin >> a[i];
- }
- i=n-1;
- int r=n-1;
- while (i>0)
- {
- while (i > 0 && a[n-1]==a[i-1]) {r--; i--;};
- if ((x + (n - r)) > a[n-1] - 1) break;
- x+=n-r;
- a[n-1]--;
- }
- if (i==0)
- cout << (x+a[n-1]*n + n)/(n+1);
- else if (a[n-1]>x)
- cout << a[n-1];
- else
- cout << x;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement