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 <iostream>
using namespace std;
long long int a[300005];
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
long long int n, c = 0, ma = 0, mi = 0;
cin >> n;
for (int i = 2; i <= n; i++) {
cin >> a[i];
c += a[i];
ma = max(ma, c);
mi = min(mi, c);
}
if (ma - mi == n - 1) {
long long int c = 0, h = 1 - mi;
for (int i = 1; i <= n; i++) {
c += a[i];
cout << h + c << " ";
}
}
else cout << -1;
}
# | 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... |