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>
typedef long long ll;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
std::cin >> n;
std::vector<ll> d(n - 1);
for (auto &i : d) {
std::cin >> i;
}
ll min = 0, max = 0;
for (ll i = 0, sum = 0; i < n - 1; ++i) {
sum += d[i];
min = std::min(min, sum);
max = std::max(max, sum);
}
if (max - min + 1 != n) {
std::cout << "-1\n";
return 0;
}
std::cout << n - max << ' ';
for (ll i = 1, sum = n - max; i < n; ++i) {
sum += d[i - 1];
std::cout << sum << ' ';
}
std::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... |