제출 #366859

#제출 시각아이디문제언어결과실행 시간메모리
366859kostia244Archery (IOI09_archery)C++17
5 / 100
2086 ms748 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 = 2020;
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++) {
		for(int i = 1; i < n; i += 2)
			if(cur[i] < cur[i-1]) swap(cur[i], cur[i-1]);
		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...