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;
using ll = long long;
int main() {
ll n, mx=0, mn=1e9, cnt=0, a=0;
cin >> n;
vector<ll> d(n);
for(int i=1; i<n; i++) cin >> d[i], d[i] += d[i-1];
for(int i=0; i<n; i++) mn = min(mn, d[i]), mx = max(mx, d[i]);
for(int i=1; i<=n; i++)
if(i + mn >= 1 && i + mn <= n && i + mx >= 1 && i + mx <= n) cnt++, a = i;
if(cnt != 1) {
cout << -1 << '\n';
return 0;
}
for(ll &x : d) cout << a + x << " ";
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... |