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;
const int MAXN=300005;
long long pref[MAXN];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int N,A;
long long prefMax=0,prefMin=0;
cin >> N;
for(int i=2;i<=N;i++){
cin >> A;
pref[i]=pref[i-1]+A;
prefMax=max(prefMax,pref[i]);
prefMin=min(prefMin,pref[i]);
}
long long bataskiri=1-prefMin,bataskanan=N-prefMax;
if(bataskiri<1)bataskiri=1;
if(bataskanan>N)bataskanan=N;
if(bataskanan==bataskiri){
for(int i=1;i<=N;i++){
cout << bataskiri+pref[i];
if(i<N)cout << " ";
else cout << '\n';
}
}
else{
cout << -1 << '\n';
return 0;
}
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... |