Submission #31958

#TimeUsernameProblemLanguageResultExecution timeMemory
31958huynd2001라멘 (JOI14_ramen)C++14
80 / 100
0 ms2036 KiB
#include "ramen.h" #include <bits/stdc++.h> // int it2[4007],it1[4007]; int a[4007]; void Ramen(int n) { for(int i=1;i<=n;i++) a[i]=i-1; int tg; for(int i=1;i<=n;i+=2) { if(i<n) { if(Compare(a[i],a[i+1])==1) tg=a[i+1],a[i+1]=a[i],a[i]=tg; } } int ma=-1,mi=-1; for(int i=1;i<=n;i+=2) { if(ma==-1) ma=a[i]; else if(Compare(ma,a[i])==1) ma=a[i]; } for(int i=2;i<=n;i+=2) { if(mi==-1) mi=a[i]; else if(Compare(mi,a[i])==-1) mi=a[i]; } if(n%2==1) { if(Compare(ma,a[n])==1) ma=a[n]; if(Compare(mi,a[n])==-1) mi=a[n]; } Answer(ma,mi); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...