Submission #1016288

#TimeUsernameProblemLanguageResultExecution timeMemory
1016288toast12Labels (NOI20_labels)C++14
0 / 100
45 ms6480 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...