# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
671140 | vuavisao | Labels (NOI20_labels) | C++14 | 50 ms | 6732 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define ll long long
using namespace std;
template<typename Lhs, typename Rhs> inline void Max_self(Lhs &a, Rhs b) { a = (a > b ? a : b); }
template<typename Lhs, typename Rhs> inline void Min_self(Lhs &a, Rhs b) { a = (a < b ? a : b); }
const ll N = 3e5 + 10;
const ll INF = 1e18;
ll n;
ll a[N];
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen("Labels.inp", "r")) {
freopen("Labels.inp", "r", stdin);
freopen("Labels.out", "w", stdout);
}
cin >> n;
for(ll i = 2; i <= n; ++ i) {
cin >> a[i];
a[i] += a[i - 1];
}
ll Min = - INF, Max = INF;
for(ll i = 2; i <= n; ++ i) {
if(a[i] == 0) {
Max_self(Min, 1);
Min_self(Max, n);
}
else if(a[i] < 0) {
Max_self(Min, abs(a[i]) + 1);
Min_self(Max, n);
}
else {
Max_self(Min, 1);
Min_self(Max, n - a[i]);
}
}
if(Min != Max) {
cout << - 1;
return 0;
}
ll first = Min;
for(ll i = 1; i <= n; ++ i) cout << first + a[i] << ' ';
return 0;
}
/// Code by vuavisao
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |