Submission #1313510

#TimeUsernameProblemLanguageResultExecution timeMemory
1313510prunjuiceLabels (NOI20_labels)C++20
100 / 100
95 ms4640 KiB
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector <int> Labels (n); int a = 0; int b = INT_MAX; int c = 0; int low = 0; int high = 0; for (int i = 0; i < n; i++){ cin >> Labels[i]; c += Labels[i]; if (c < b){ b = c; } if (c > a){ a = c; } } low = 1 - b; if (low <= 0){ low = 1; } high = n - a; if (low == high){ vector <int> A (n); A[0] = low; cout << A[0] << " "; for (int i = 1; i < n; i++){ A[i] = A[i - 1] + Labels[i - 1]; cout << A[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...