#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
ll n, pre=0, mx=0, mi=0;
cin>>n;
ll d[n];
ll a[n];
for(ll i=1; i<=n-1; i++)
{
cin>>d[i];
pre+=d[i];
}
a[n]=pre+1;
mx=max(mx, a[n]);
mi=min(mi, a[n]);
for(ll i=n-1; i>=1; i--)
{
a[i]=a[i+1] - d[i];
mx=max(mx, a[i]);
mi=min(mi, a[i]);
}
if(mx-mi == n)
{
for(ll i=1; i<=n; i++)
cout<<a[i] <<" ";
}
else
cout<<-1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
7508 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
48 ms |
5860 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |