This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+1;
int n, d[N], a[N];
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i=2; i<=n; ++i) cin >> d[i];
partial_sum(d, d+n+1, a);
int m=*min_element(a+1, a+n+1);
for (int i=1; i<=n; ++i) a[i]=a[i]+1-m;
m=*max_element(a+1, a+n+1);
if (m!=n){
cout << -1;
return 0;
}
for (int i=1; i<=n; ++i) cout << a[i] << " \n"[i==n];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |