Submission #1249270

#TimeUsernameProblemLanguageResultExecution timeMemory
1249270nasjesLabels (NOI20_labels)C++20
100 / 100
30 ms4784 KiB
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <string>
#include <cstring>
#include <iterator>
#include <random>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;
const ll dim = 2*(1e6)+7;
//const ll mod = 1e9 + 7;
const ll inf = 1e17 + 77;
#define endl "\n"
#define fi first
#define pb push_back
#define se second
#define vll vector<ll>

ll n, m, k;
ll a[dim], dp[dim];
int main() {

    ll  u, w,q,   v, y;
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    ll mn=n;
    ll mx=0;
    ll sm=0;
    for(int i=1; i<=n-1; i++){
        cin>>a[i];
        sm+=a[i];
        mn=min(mn, sm);
        mx=max(mx, sm);
    }
    ll l=1;
    ll r=n;
    l=max<ll>(1, 1-mn);
    r=min(n, n-mx);
    if(l==r){
        sm=l;
        cout<<l<<" ";
        for(int i=1; i<=n-1; i++){
            sm+=a[i];
            cout<<sm<<" ";
        }
        cout<<endl;
    }
    else{
        cout<<-1<<endl;
    }
    return 0;
}
#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...