#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,f[300009],mn,mx,pas[300009],ff[300009];
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a;
for(i=1; i<a; i++){
cin>>f[i];ff[i]=f[i];
}
for(i=a; i>=1; i--) f[i]+=f[i+1];
mn=300002;
mx=-mn;xc=-2;
for(i=a-1; i>=1; i--){
if(mn>f[i]) mn=f[i];
if(mx<f[i]) mx=f[i];
if(f[i]-mn==a-1){
zx=i;xc=1;
}
if(f[i]-mx==-(a-1)){
zx=i;xc=a;
}
}
if(xc==-2){
cout<<-1;
return 0;
}
pas[zx]=xc;
for(i=zx+1; i<=a; i++){
pas[i]=pas[i-1]+ff[i-1];
}
for(i=zx-1; i>=1; i--){
pas[i]=pas[i+1]-ff[i+1];
}
for(i=1; i<=a; i++) cout<<pas[i]<<" ";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
3136 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |