Submission #759545

#TimeUsernameProblemLanguageResultExecution timeMemory
759545Niko_shmikoXylophone (JOI18_xylophone)C++17
100 / 100
75 ms416 KiB
#include "xylophone.h" #include<bits/stdc++.h> void solve(int N){ int mni=0, mxi=0, a[N]; a[0]=0; a[1]=query(1, 2); for(int i=2; i<N; i++){ a[i]=abs(query(i, i+1))+a[i-1]; if(a[i-2]<a[i-1]){ if(query(i-1, i+1)!=abs(a[i]-a[i-2])){ a[i]-=a[i-1]; a[i]*=-1; a[i]+=a[i-1]; } }else{ if(query(i-1, i+1)==a[i]-a[i-1]+a[i-2]-a[i-1]){ a[i]-=a[i-1]; a[i]*=-1; a[i]+=a[i-1]; } } } for(int i=0; i<N; i++){ if(a[i]<a[mni]){ mni=i; } if(a[i]>a[mxi]){ mxi=i; } } if(mni>mxi){ mni=-1; }else{ mni=1; } for(int i=0; i<N; i++){ a[i]=a[i]*mni; if(mxi>a[i]){ mxi=a[i]; } } for(int i=0; i<N; i++){ answer(i+1, a[i]-mxi+1); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...