#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
int main(){
int n;
cin>>n;
vi d,pref, ori;
for(int i = 0; i < n-1; i++){
int a;
cin>>a;
d.pb(a);
}
pref.pb(d[0]);
for(int i = 1; i < n - 1; i++)
pref.pb(d[i] + pref[i-1]);
ori = pref;
sort(pref.begin(),pref.end());
bool begin = false, end = false;
if(pref[pref.size()-1] + 1 == n)
begin = true;
if(abs(pref[0]) + 1 == n)
end = true;
if(begin){
for(int i = 0; i < n; i++)
{
if(i == 0)
cout<<1<<" ";
else
cout<<ori[i-1] + 1<<" ";
}
}
else if(end){
for(int i = 0; i < n; i++)
{
if(i == 0)
cout<<n<<" ";
else
cout<<ori[i-1] + n<<" ";
}
}
else{
cout<<-1<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
99 ms |
5980 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
110 ms |
5980 KB |
Output is correct |
4 |
Correct |
58 ms |
4572 KB |
Output is correct |
5 |
Correct |
73 ms |
4572 KB |
Output is correct |
6 |
Correct |
69 ms |
4572 KB |
Output is correct |
7 |
Correct |
64 ms |
5212 KB |
Output is correct |
8 |
Correct |
70 ms |
5212 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |