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 <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(int i=(signed)(a); i<=(signed)(b); i++)
#define F0R(i, a) for(int i=(signed)(0); i<(signed)(a); i++)
const int MXN = 3e5 + 10;
int diff[MXN] = {0};
int ps[MXN] = {0};
int main(){
//faster io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin>>N;
FOR(i, 2, N){
cin>>diff[i];
}
ps[1] = 1;
int mx = 1;
FOR(i, 2, N){
ps[i] = ps[i-1] + diff[i];
mx = max(mx, ps[i]);
}
if(mx==N){
FOR(i, 1, N) cout<<ps[i]<<" ";
cout<<"\n";
}
else{
cout<<"-1\n";
}
}
# | 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... |