Submission #1018097

#TimeUsernameProblemLanguageResultExecution timeMemory
1018097tigarXylophone (JOI18_xylophone)C++17
0 / 100
0 ms344 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; int ans1[5050], ans2[5050]; int mn2=0, mnp2=1, mn1=0, mnp1=1, mx1=0, mxp1=1, mx2=0, mxp2=1; void solve(int N) { ans1[1]=0; ans2[1]=0; ans1[2]=query(1, 2); ans2[2]=-query(1, 2); int hlast=ans1[2]; for(int i=3; i<=N; i++) { int h1=query(i-1, i), h2=query(i-2, i); if(hlast+h1==h2) { if(ans1[i-1]>ans1[i-2])ans1[i]=h1+ans1[i-1]; else ans1[i]=ans1[i-1]-h1; if(ans2[i-1]>ans2[i-2])ans2[i]=h1+ans2[i-1]; else ans2[i]=ans2[i-1]-h1; } else { if(ans1[i-1]<ans1[i-2])ans1[i]=h1+ans1[i-1]; else ans1[i]=ans1[i-1]-h1; if(ans2[i-1]<ans2[i-2])ans2[i]=h1+ans2[i-1]; else ans2[i]=ans2[i-1]-h1; } if(ans1[i]<mn1){mn1=min(mn1, ans1[i]); mnp1=i;} if(ans2[i]<mn2){mn2=min(mn2, ans2[i]); mnp2=i;} if(ans1[i]>mx1){mx1=max(mx1, ans1[i]); mxp1=i;} if(ans2[i]>mx2){mx2=max(mx2, ans2[i]); mxp2=i;} hlast=h1; } if(mxp1>mnp1) { for(int i=1; i<=N; i++)answer(i, ans1[i]-mn1+1); } else { for(int i=1; i<=N; i++)answer(i, ans2[i]-mn2+1); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...