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;
typedef long long ll;
int32_t main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int N;
cin >> N;
vector<int> arr(N, 1);
// set<int> s;
// s.insert(1);
int mn = 1, mx = 1;
for (int i = 1;i < N;i ++) {
int x;
cin >> x;
arr[i] = arr[i - 1] + x;
// s.insert(arr[i]);
mn = min(mn, arr[i]);
mx = max(mx, arr[i]);
}
// cout << mx << " " << mn << "\n";
if ((mx - mn + 1) != N) {
cout << "-1\n";
return 0;
}
mn = -mn + 1;
for (int i = 0;i < N;i ++) {
arr[i] += mn;
cout << arr[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... |