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>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back
void solve() {
int n;
cin>>n;
ll d[n-1],a[n],m1=0,m2=0;
a[0]=0;
for(int i=0;i<n-1;i++){
cin>>d[i];
a[i+1]=a[i]+d[i];
m1=min(m1,a[i+1]);
m2=max(m2,a[i+1]);
}
if(m2-m1!=n-1){
cout<<-1;
return;
}
for(int i=0;i<n;i++)cout<<a[i]-m1+1<<' ';
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
solve();
}
# | 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... |