#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define pp pair<ll,int>
#define ub(x,i) upper_bound(all(x),i)-x.begin()
#define lb(x,i) lower_bound(all(x),i)-x.begin()
#define t3 tuple<int,int,int>
using namespace std;
const int mxn=4e5+5;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n;cin>>n;ll d[n]={0};
for(int i=1;i<=n-1;i++)cin>>d[i],d[i]+=d[i-1];
ll mn = *min_element(d+1,d+n);
ll mx = *max_element(d+1,d+n);
if((n-mx)==max(1ll,1-mn)&&1<=n-mx&&n-mx<=n){
cout<<n-mx<<' ';for(int i=1;i<=n-1;i++)cout<<n-mx+d[i]<<' ';
}
else cout<<-1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |