Submission #1318127

#TimeUsernameProblemLanguageResultExecution timeMemory
1318127aaakkksssiiinnnGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define f first
#define s second
#define pb push_back
#define yes cout << "yes" << endl;
#define YES cout << "YES" << endl;
#define no cout << "no" << endl;
#define NO cout << "NO" << endl;
void never_give_up() {
    int n;
    cin >> n;
    vector<int>vt(n + 1);
    for(int i = 1;i <= n; i++){
        cin >> vt[i];
    }
    int cvb = 0;
    for(int i = n; i >= 2; i--){
        if(vt[i] >= vt[i - 1]){
            int k = vt[i] - vt[i - 1] + 1;
            for(int j = i - 1; j >= 1; j--){
                vt[j] += k;
            }
            cvb += k;
            //cout << i << " " << k << endl;
        }
        /*cout << i << " : ";
        for(int j = 1;j <= n; j++){
            cout << vt[j] << " ";
        }
        cout << endl;*/
    }
    cout << cvb << endl;
}
void You_can_do_it() {
    //cout << 4096 + 512 + 256 + 128;
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int THE_wasd = 1;               
    //cin >> THE_wasd;
    while(THE_wasd--){
        never_give_up();
        //You_can_do_it();
    }
}









//1 2 4 8 16 32 64 128 256 512 1024 2048 4096 













#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...