This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
ID: samikgo1
TASK:
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
//#define f first
//#define s second
//#define x first
//#define y second
const int INF = INT32_MAX;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// freopen("measurement.in","r",stdin);
// freopen("measurement.out","w",stdout);
int n;
cin >> n;
vector<ll> arr(n-1);
for(ll&i:arr)cin>>i;
vector<ll> prefix(n);
ll min_p = 0;
ll max_p = 0;
for (int i = 1; i < n; i++) {
prefix[i] = prefix[i - 1] + arr[i - 1];
min_p = min(min_p,prefix[i]);
max_p = max(max_p,prefix[i]);
}
if(n-max_p!=1-min_p){cout<<"-1";return 0;}
for(ll&i:prefix){
cout << i+1-min_p << ' ';
}
}
# | 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... |