Submission #1057878

#TimeUsernameProblemLanguageResultExecution timeMemory
1057878hennesseyLabels (NOI20_labels)C++17
100 / 100
76 ms18612 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { //your code goes here int n; cin >> n; vector <int> arr = {}; for(int i = 1; i < n; i++) { int num; cin >> num; arr.push_back(num); } vector <int> pref = {0}; int cur = 0; for(int i = 0; i < n-1; i++) { cur += arr[i]; // cout << cur << endl; pref.push_back(cur); } int minv = 1e18; int maxv = 0; for(int i = 0; i < n; i++) { // cout << pref[i] << endl; maxv = max(maxv, pref[i]); minv = min(minv, pref[i]); } int ans = 0; int ch = -1; for(int i = 1; i <= n; i++) { if((maxv+i) <= n && (i+minv) >= 1) { ans++; ch = i; } } // cout << ans << " " << maxv << " " << minv << endl; if(ans > 1) { cout << -1 << endl; } else { vector <int> ans = {}; for(int i = 0; i < n; i++) { ans.push_back((ch+pref[i])); } for(int i = 0; i < n; i++) { cout << ans[i] << " "; } cout << endl; } 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...