제출 #537719

#제출 시각아이디문제언어결과실행 시간메모리
537719_karan_gandhiLabels (NOI20_labels)C++17
25 / 100
149 ms19628 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() #define endl '\n' #define pl(var) " [" << #var << ": " << (var) << "] " #define ll long long void solve() { int n; cin >> n; vector<int> diff(n - 1); for (int i = 0; i < n - 1; i++) cin >> diff[i]; vector<int> ans(n, 0); for (int i = 0; i < n - 1; i++) { ans[i + 1] = ans[i] + diff[i]; } int mn = *min_element(all(ans)); for (int i = 0; i < n; i++) { ans[i] -= mn - 1; } map<int, bool> done; for (int i = 0; i < n; i++) { if (done[ans[i]]) { cout << "-1" << endl; return; } else { done[ans[i]] = 1; } } for (auto A : ans) cout << A << ' '; cout << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T = 1; // cin >> T; while (T--) solve(); }
#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...