Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <bitset>
- #include <cassert>
- #include <cctype>
- #include <cmath>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <ctime>
- #include <iomanip>
- #include <iostream>
- #include <map>
- #include <queue>
- #include <set>
- #include <sstream>
- #include <string>
- #include <vector>
- using namespace std;
- const int MAXN = 100;
- int n, a[MAXN];
- int main() {
- ios_base::sync_with_stdio(0);
- #ifdef ACMTUYO
- freopen("in.txt","r",stdin);
- freopen("out.txt","w",stdout);
- clock_t start = clock();
- #endif
- while (cin >> n) {
- int sum = 0;
- for (int i = 0; i < n; ++i) {
- cin >> a[i];
- sum += a[i];
- }
- int ans = 0;
- while (true) {
- int mag = -1, id = -1;
- for (int i = 1; i < n; ++i) {
- if (a[i] > mag) {
- mag = a[i];
- id = i;
- }
- }
- if (a[0] > mag)
- break;
- --a[id];
- ++a[0];
- ++ans;
- }
- cout << ans << '\n';
- }
- #ifdef ACMTUYO
- fprintf(stderr, "\ntime=%.3lfsec\n", 1. * (clock() - start) / CLOCKS_PER_SEC);
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement