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> d(n-1);
for (int i = 0; i < n-1; i++)
cin >> d[i];
vector <int> nums(n);
nums[0] = 1;
bool possible = true;
for (int i = 0; i < n; i++) {
nums[i+1] = nums[i] + d[i];
if (nums[i+1] <= 0)
possible = false;
}
if (!possible || *max_element(nums.begin(), nums.end()) < n)
cout << -1 << '\n';
else {
for (auto i : nums)
cout << i << ' ';
cout << '\n';
}
}
# | 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... |