Submission #988962

#TimeUsernameProblemLanguageResultExecution timeMemory
988962hmm789Archery (IOI09_archery)C++14
22 / 100
2101 ms9820 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long 

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, r, x;
	cin >> n >> r >> x;
	r %= (2*n);
	int b[2*n-1];
	for(int i = 0; i < 2*n-1; i++) cin >> b[i];
	int a[2][2*n];
	bool flag = 0;
	int mn = n-1, ans = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 2*n; j++) a[0][j] = 0;
		a[0][2*i] = x;
		int idx = 0;
		for(int j = 0; j < 2*n; j++) if(!a[0][j]) {
			a[0][j] = b[idx++];
		}
		flag = 0;
		for(int j = 0; j < 2*n+r; j++) {
			for(int k = 1; k < n; k++) {
				a[flag^1][2*(k-1)] = min(a[flag][2*k], a[flag][2*k+1]);
				a[flag^1][2*k+1] = max(a[flag][2*k], a[flag][2*k+1]);
			}
			a[flag^1][2*n-2] = max(a[flag][0], a[flag][1]);
			a[flag^1][1] = min(a[flag][0], a[flag][1]);
			flag ^= 1;
		}
		for(int j = 0; j < 2*n; j++) if(a[flag][j] == x) {
			if(j/2 < mn) {
				mn = j/2;
				ans = i;
			} else if(j/2 == mn) {
				ans = max(ans, i);
			}
		}
	}
	cout << ans+1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...