Submission #1006589

#TimeUsernameProblemLanguageResultExecution timeMemory
1006589huutuanArchery (IOI09_archery)C++14
10 / 100
2096 ms3928 KiB
#include <bits/stdc++.h> using namespace std; const int N=5e5+10; int n, r, s, a[N], b[N]; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> r >> s; r=(r-n*2)%(n*2)+n*2; for (int i=1; i<n*2; ++i) cin >> b[i]; pair<int, int> ans={n*2, n}; for (int i=1; i<=n; ++i){ for (int j=1; j<i*2; ++j) a[j]=b[j]; a[i*2]=s; for (int j=i*2+1; j<=n*2; ++j) a[j]=b[j-1]; for (int _=1; _<=r; ++_){ for (int j=1; j<=n*2; j+=2) if (a[j]>a[j+1]) swap(a[j], a[j+1]); swap(a[1], a[2]); int tmp=a[1]; for (int j=3; j<=n*2; j+=2) a[j-2]=a[j]; a[n*2-1]=tmp; } int pos=0; for (int j=1; j<=n*2; ++j) if (a[j]==s) pos=(j+1)/2; ans=min(ans, {pos, i}); } cout << ans.second << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...