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;
long long n,d[2000005],man,mix,ans,x,cur,a[200005];
int main(){
cin >> n;
man = 1e18;
for(int i = 1; i < n; i++){
cin >> d[i];
ans += d[i];
mix = max(mix,ans);
man = min(man,ans);
}
for(int i = 1; i <= n; i++){
if(i + ans >= 1 && i + ans <= n && i + mix >= 1 && i + mix <= n && i + man >= 1 && i + man <= n){
x++;
cur = i;
}
}
if(x == 1){
a[1] = cur;
for(int i = 1; i < n; i++){
a[i + 1] = a[i] + d[i];
cout << a[i] << " ";
}
cout << a[n];
} else cout << -1 << endl;
}
# | 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... |