Submission #899245

#TimeUsernameProblemLanguageResultExecution timeMemory
899245BlagojLabels (NOI20_labels)C++17
0 / 100
29 ms6480 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define all(x) (x).begin(), (x).end() int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int d[n - 1]; int add = 1, sum = 1; for (int i = 0; i < n - 1; i++) { cin >> d[i]; sum += d[i]; if (sum < 0) { add += abs(sum); sum = 0; } if (sum > n) cout << -1 << endl; } vector<int> ans(n); ans[0] = add; for (int i = 0; i < n - 1; i++) ans[i + 1] = ans[i] + d[i]; for (int i = 0; i < n; i++) { if (ans[i] < 0 || ans[i] > n) { cout << -1; return 0; } } add++; vector<int> newAns(n); newAns[0] = add; for (int i = 0; i < n - 1; i++) newAns[i + 1] = newAns[i] + d[i]; for (int i = 0; i < n; i++) { if (newAns[i] < 0 || newAns[i] > n) { for (int i = 0; i < n; i++) cout << ans[i] << " "; return 0; } } 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...