Submission #284849

#TimeUsernameProblemLanguageResultExecution timeMemory
284849mosiashvililukaLabels (NOI20_labels)C++14
100 / 100
93 ms6648 KiB
#include<bits/stdc++.h> using namespace std; int a,b,c,d,e,i,j,ii,jj,zx,xc,f[300009],mn,mx,pas[300009],ff[300009]; int main(){ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>a; for(i=1; i<a; i++){ cin>>f[i];ff[i]=f[i]; } for(i=a; i>=1; i--) f[i]+=f[i+1]; mn=0; mx=0;xc=-2; for(i=a-1; i>=1; i--){ if(mn>f[i]) mn=f[i]; if(mx<f[i]) mx=f[i]; if(f[i]-mn==a-1){ zx=i;xc=1; } if(f[i]-mx==-(a-1)){ zx=i;xc=a; } } if(xc==-2){ cout<<-1; return 0; } pas[zx]=xc; for(i=zx+1; i<=a; i++){ pas[i]=pas[i-1]+ff[i-1]; } for(i=zx-1; i>=1; i--){ pas[i]=pas[i+1]-ff[i]; } for(i=1; i<=a; i++) cout<<pas[i]<<" "; 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...