제출 #366865

#제출 시각아이디문제언어결과실행 시간메모리
366865kostia244Archery (IOI09_archery)C++17
20 / 100
2090 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 = 4002; int n, r, p = 0, a[maxn], sp = 0; char cur[maxn]; 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]) { cur[i] ^= cur[i-1]; cur[i-1] ^= cur[i]; cur[i] ^= cur[i-1]; } int FF = cur[1]; #pragma GCC ivdep for(int i = 1; i+1 < n; i++) cur[i] = cur[i+1]; cur[n-1] = FF; } 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...