Submission #294553

#TimeUsernameProblemLanguageResultExecution timeMemory
294553nandonathanielLabels (NOI20_labels)C++14
100 / 100
71 ms6776 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...