#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int N;
cin>>N;
int arr[N];
int s[N];
arr[0] = 1;
s[0] = 1;
int add=0;
for (int i=1; i<N; i++){
int temp;
cin>>temp;
arr[i] = arr[i-1]+temp;
if (arr[i]<0) add = max(0-arr[i], add);
s[i] = arr[i];
}
sort (s, s+N);
//for (int j=0; j<N; j++) cout<<s[j]<<endl;
if (s[0]==1 && s[N-1]==N) for (int j=0; j<N; j++) cout<<add+arr[j]<<' ';
else cout<<-1<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
4548 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
45 ms |
2648 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |