# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1016288 |
2024-07-07T16:54:09 Z |
toast12 |
Labels (NOI20_labels) |
C++14 |
|
45 ms |
6480 KB |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> nums(n);
for (int i = 1; i < n; i++) {
cin >> nums[i];
}
vector<int> ps(n);
for (int i = 1; i < n; i++) {
ps[i] = ps[i-1]+nums[i];
}
auto it = max_element(ps.begin(), ps.end());
if (*it != n-1) {
cout << "-1\n";
return 0;
}
vector<int> ans(n);
int idx = it-ps.begin();
ans[idx] = n;
for (int i = idx+1; i < n; i++) {
ans[i] = ans[i-1]+nums[i];
}
for (int i = idx-1; i >= 0; i--) {
ans[i] = ans[i+1]-nums[i+1];
}
for (int i = 0; i < n; i++) {
cout << ans[i] << ' ';
}
cout << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
6480 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
31 ms |
3412 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |