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;
#define fixbug true
#define ll long long
const int maxn = 3e5;
int D[maxn+2] , sum = 0;
int n;
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
#define name "main"
//freopen(name".inp","r",stdin);
//freopen(name".out","w",stdout);
cin >> n;
ll mn = n + 1 , mx = 0 , sum = 0;
for (int i = 1; i < n; ++i){
cin >> D[i];
sum += D[i];
mn = min(mn , sum);
mx = max(mx , sum);
}
int p = -1;
for (int i = 1; i <= n; ++i){
if (mn + i > 0 && mx + i <= n){
if (p!=-1){
cout << -1;
exit(0);
}
p = i;
}
}
if (p==-1){ cout << -1; exit(0);}
cout << p << ' ';
for (int i = 1; i < n; ++i) {
p += D[i];
cout << p << ' ';
}
exit(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... |