#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define INF 1e9
#define fori(x,y,z) for(ll x=y;x<=z;x++)
#define pb push_back
int main(){
// The following line disables syncing between cin/scanf and cout/printf.
// It makes input faster, but you must not use functions from <cstdio> (e.g. scanf/printf) directly.
// This line must be executed before any use of cin/cout.
ios_base::sync_with_stdio(false);
// Your code goes here ...
// (You can now read input and write output normally using cin/cout.)
ll n;
cin>>n;
vector<ll>d(n+10);
ll sum=0;
ll minimum=INF,have=0;
fori(i,1,n-1){
ll a;
cin>>a;
sum+=a;
d[i]=sum;
if(a==0)
have=1;
minimum=min(d[i],minimum);
}
vector<ll>ans;
if(have==1){
cout<<-1;
return 0;
}
if(minimum<0){
minimum=abs(minimum)+1;
ans.pb(minimum);
fori(i,1,n-1){
ans.pb(d[i]+minimum);
}
}
else{
minimum=1;
ans.pb(minimum);
fori(i,1,n-1){
ans.pb(d[i]+minimum);
}
}
fori(i,0,n-1)
cout<<ans[i]<<' ';
}
# | 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... |