// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector <int> Labels (n);
int a = 0;
int b = INT_MAX;
int c = 0;
int low = 0;
int high = 0;
for (int i = 0; i < n; i++){
cin >> Labels[i];
c += Labels[i];
if (c < b){
b = c;
}
if (c > a){
a = c;
}
}
low = 1 - b;
if (low <= 0){
low = 1;
}
high = n - a;
if (low == high){
vector <int> A (n);
A[0] = low;
cout << A[0] << " ";
for (int i = 1; i < n; i++){
A[i] = A[i - 1] + Labels[i - 1];
cout << A[i] << " ";
}
}
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... |