Submission #366862

#TimeUsernameProblemLanguageResultExecution timeMemory
366862kostia244Archery (IOI09_archery)C++17
12 / 100
2077 ms620 KiB
#pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx,avx2,sse,sse2") #include<bits/stdc++.h> using namespace std; using ll = long long; #define all(x) begin(x), end(x) const int maxn = 404; int n, r, p = 0, a[maxn], cur[maxn], sp = 0; array<int, 2> ans = {100000, -1}; void check() { for(int i = 0; i < n; i++) cur[i] = a[i]; //for(int i = 0; i < n; i++) cout << cur[i] << " "; cout << endl; for(int it = 0; it < r; it++) { #pragma GCC ivdep for(int i = 1; i < n; i += 2) if(cur[i] < cur[i-1]) swap(cur[i], cur[i-1]); #pragma GCC ivdep for(int i = 2; i < n; i++) swap(cur[i], cur[i-1]); } int pos = 0; while(cur[pos]) pos++; ans = min(ans, {pos, -sp}); } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> r; n *= 2; r = r%(2*n); r += 2*n; cin >> p; for(int i = 1; i < n; i++) { cin >> a[i]; } for(int i = 1; i < n; i++) { a[i] = a[i] < p ? -1 : 1; } check(); for(int i = 1; i < n; i++) { swap(a[i], a[i-1]); sp++; check(); } cout << 1 + ((-ans[1])/2) << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...