#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define coutpair(p) cout << p.first << " " << p.second << "|"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n; cin >> n;
ll a[n];
for (int i=1; i<n; i++) cin >> a[i];
ll lab[n]; lab[0] = 1;
ll neg = 0;
for (int i=1; i<n; i++){
lab[i] = lab[i-1]+a[i];
if (lab[i] <= 0) neg = max(neg, abs(lab[i])+1);
}
for (int i=0; i<n; i++) lab[i] += neg;
bool mx = false, mn = false;
for (int i=0; i<n; i++){
if (lab[i] == n) mx = true;
if (lab[i] == 1) mn = true;
}
if (mx && mn){
for (auto it : lab) cout << it << " ";
}
else cout << -1;
return 0;
}
# | 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... |