#include<bits/stdc++.h>
#define deb(x) cout << #x << ": " << x << endl
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n;
cin>>n;
long long f[n-1];
for(int i=0;i<n-1;i++) cin>>f[i];
long long sum=0,status=0;
for(int i=0;i<n-1;i++){
sum+=f[i];
if(abs(sum)>n-1){
status=2;
break;
}
}
if(status!=2){
for(int i=0;i<n-1;i++){
sum+=f[i];
if(abs(sum)==n-1){
status=1;
break;
}
}
}
if(status==0||status==2) cout<<"-1";
else{
if(sum==n*-1+1){
long long l=n;
cout<<n<<" ";
for(int i=0;i<n-1;i++){
cout<<l+f[i]<<" ";
l+=f[i];
}
}
else{
long long l=1;
cout<<"1 ";
for(int i=0;i<n-1;i++){
cout<<l+f[i]<<" ";
l+=f[i];
}
}
}
return(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
2668 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |