Submission #1240180

#TimeUsernameProblemLanguageResultExecution timeMemory
1240180karen671Labels (NOI20_labels)C++20
100 / 100
35 ms7336 KiB
#include <iostream>
#include <vector>

typedef long long ll;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    ll n;
    std::vector<ll> d;

    std::cin >> n;
    d.resize(n-1);

    for (ll i = 0; i < n-1; i++) {
        std::cin >> d[i];
    }

    std::vector<ll> pref(n);
    for (ll i = 0; i < n-1; i++) {
        pref[i+1] = pref[i] + d[i];
    }

    ll maxx = -1;
    for (ll i = 0; i < n; i++) {
        if (pref[i] > maxx) {
            maxx = pref[i];
        }
    }

    ll minn = 1'000'000'000;
    for (ll i = 0; i < n; i++) {
        if (pref[i] < minn) {
            minn = pref[i];
        }
    }

   if (maxx - minn != n-1) {
       std::cout << -1;
       return 0;
   }

    for (ll i = 0; i < n; i++) {
        std::cout << pref[i] + std::abs(minn) + 1 << " ";
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...