Submission #538736

#TimeUsernameProblemLanguageResultExecution timeMemory
538736dsyzLabels (NOI20_labels)C++17
100 / 100
79 ms9012 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define MAXN (1000005) int main() { ios_base::sync_with_stdio(false);cin.tie(0); ll N; cin>>N; ll D[N - 1]; for(ll i = 0;i < N - 1;i++){ cin>>D[i]; } ll arr[N]; memset(arr,0,sizeof(0)); ll minimum = 1; ll maximum = N; ll prefixsum = 0; for(ll i = 0;i < N - 1;i++){ prefixsum += D[i]; if(prefixsum <= 0){ minimum = max(minimum,-1 * prefixsum + 1); } if(prefixsum >= 0){ maximum = min(maximum,N - prefixsum); } } if(minimum < 1 || maximum > N || minimum > maximum || maximum - minimum >= 1){ cout<<-1<<'\n'; }else{ arr[0] = maximum; for(ll i = 1;i < N;i++){ arr[i] = arr[i - 1] + D[i - 1]; } for(ll i = 0;i < N;i++){ cout<<arr[i]<<" "; } cout<<'\n'; } }
#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...