Submission #525340

#TimeUsernameProblemLanguageResultExecution timeMemory
525340safaricolaXylophone (JOI18_xylophone)C++17
0 / 100
0 ms200 KiB
#include "xylophone.h" static int ans[5010],diff1[5010],diff2[5010],mi,ma,miid,maid; bool greater[5010]; void solve(int N) { for(int i=1; i<N; i++){ diff1[i]=query(i,i+1); if(i!=N-1){ diff2[i]=query(i,i+2); } } ans[1]=1; //greater=1, i<i+1; for(int i=1; i<N; i++){ if(greater[i]){ ans[i+1]=ans[i]+diff1[i]; if(ans[i+1]>ma){ ma=ans[i+1]; maid=i+1; } } else{ ans[i+1]=ans[i]-diff1[i]; if(ans[i+1]<mi){ mi=ans[i+1]; miid=i+1; } } if(diff1[i+1]<diff2[i]){ greater[i+1]=greater[i]; }else{ greater[i+1]=!greater[i]; } } if(mi<1){ for(int i=1; i<=N; i++){ ans[i]+=i-mi; } } if(miid>maid){ for(int i=1; i<=N; i++){ ans[i]=N+1-ans[i]; } } for(int i = 1; i <= N; i++) { answer(i, ans[i]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...