Submission #1067974

#TimeUsernameProblemLanguageResultExecution timeMemory
106797412345678Archery (IOI09_archery)C++17
3 / 100
2098 ms1116 KiB
#include <bits/stdc++.h> using namespace std; const int nx=205; int n, r, res=INT_MAX, st; vector<int> p(2*nx), pw(2*nx), npw(2*nx); int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>r; //r=(r%n)+2*n; for (int i=0; i<2*n; i++) cin>>p[i]; for (int i=0; i<2*n; i++) { pw[i]=p[0]; for (int j=0; j<i; j++) pw[j]=p[j+1]; for (int j=i+1; j<2*n; j++) pw[j]=p[j]; for (int t=0; t<r; t++) { for (int j=2; j<2*n; j+=2) { if (pw[j]<pw[j+1]) npw[j-2]=pw[j], npw[j+1]=pw[j+1]; else npw[j-2]=pw[j+1], npw[j+1]=pw[j]; } if (pw[0]<pw[1]) npw[1]=pw[0], npw[2*(n-1)]=pw[1]; else npw[1]=pw[1], npw[2*(n-1)]=pw[0]; pw=npw; } //cout<<"st "<<i<<": "; //for (int j=0; j<2*n; j++) cout<<pw[j]<<' '; //cout<<'\n'; for (int j=0; j<2*n; j++) { if (pw[j]==p[0]) { if (j/2<res) res=j/2, st=(i/2)+1; } } } cout<<res+1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...