# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
676489 | penguin133 | Labels (NOI20_labels) | C++17 | 170 ms | 7920 KiB |
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 arr[300005];
int ans[300005];
int a[300005];
int main(){
int n;
cin >> n;
int cnt = 0,maxi = 0;
for(int i=1;i<n;i++){
cin >> arr[i];
}
int f = 0;
for(int i=1;i<n;i++){
cnt += arr[i];
maxi = max(maxi, cnt);
}
ans[0] = n - maxi;
a[n-maxi]++;
for(int i=1;i<n;i++){
ans[i] = ans[i-1] + arr[i];
a[ans[i]]++;
}
if(a[1] == 0 || a[n] == 0){
cout << "-1";
exit(0);
}
for(int i=0;i<n;i++){
cout << ans[i] << " ";
}
}
Compilation message (stderr)
# | 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... |