Cod sursa(job #1497282)

Utilizator tiby10Tibi P tiby10 Data 6 octombrie 2015 16:53:22
Problema Distante Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <bits/stdc++.h>
using namespace std;
int i, n, v[103], index, t;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    #endif // ONLINE_JUDGE
    cin>>n;
    for(; i<n; ++i)
        cin>>v[i];
    while(true){
        index=0;
        for(i=1; i<n; ++i)
            if(v[i]>=v[index])
                index=i;
        if(!index){
            cout<<t;
            return 0;
        }
        ++t;
        ++v[0];
        --v[index];
    }
    return 0;
}