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>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
using namespace std;
const int maxn = 300100;
ll n, d[maxn];
int main() {
cin>>n;
ll minpoint = INT_MAX, maxpoint = INT_MIN;
ll sum = 0LL;
for(int i=1;i<n;i++) {
cin>>d[i];
sum += d[i];
minpoint = min(minpoint, sum);
maxpoint = max(maxpoint, sum);
}
vector<int>starts;
for(int i=1;i<=n;i++) {
if(i + minpoint >= 1 && i + maxpoint <= n) starts.pb(i);
}
if(sz(starts) != 1) {
cout<<"-1\n";
return 0;
}
int curr = starts[0];
cout<<curr<<" ";
for(int i=1;i<n;i++) {
curr += d[i];
cout<<curr<<" ";
} cout<<"\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... |