Submission #320627

#TimeUsernameProblemLanguageResultExecution timeMemory
320627robosapienLabels (NOI20_labels)C++17
0 / 100
49 ms4816 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int n; cin >> n; int a[n] = {}; int pref = 0, mx_pref = INT_MIN; for(int i = 0; i < n - 1; ++i) { cin >> a[i]; pref += a[i]; mx_pref = max(mx_pref, pref); } if(mx_pref != n - 1) { cout << -1; } else { int first = n; pref = 0; for(int i = 0; i < n - 1; ++i) { pref += a[i]; first = min(first, max(1, 1 - pref)); } pref = 0; vector<int> ans(n); bool ok = true; for(int i = 0; i < n; ++i) { ans.push_back(first + pref); pref += a[i]; if(first + pref < 1 or first + pref > n) ok = false; } if(ok){ for(int i = 0; i < n; ++i) cout << ans[i] << " "; } else { cout << -1; } } }
#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...