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;
int main() {
int n;
cin >> n;
vector<int> delta(n-1);
vector<int> nums(n);
for (int i = 0; i < n-1; i++) cin >> delta[i];
nums[0] = 1;
int mini = 1;
int maxi = 1;
for (int i = 0; i < n-1; i++) {
nums[i+1] = nums[i] + delta[i];
mini = min(nums[i+1], mini);
maxi = max(nums[i+1], maxi);
}
int shift = 1 - mini;
maxi += shift;
if (maxi != n) {
cout << "-1";
return 0;
}
for (int i = 0; i < n; i++) {
cout << nums[i]+shift << " ";
}
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... |