比赛 EYOI与SBOI开学欢乐赛6th 评测结果 WWAATTTTTT
题目名称 IOI2099 最终得分 20
用户昵称 HeSn 运行时间 6.867 s
代码语言 C++ 内存使用 7.26 MiB
提交时间 2022-09-19 21:03:07
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 100010;
int n, k, a[MAXN], c[MAXN], maxn;
signed main() {
	freopen("player.in", "r", stdin);
	freopen("player.out", "w", stdout);
	cin >> n >> k;
	for(int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	for(int i = 1; i <= n; i ++) {
		if(i + k - 1 > n) {
			continue;
		}
		for(int j = i + k - 1; j <= n; j ++) {
			int cnt = 0;
			for(int l = i; l <= j; l ++) {
				c[++ cnt] = a[l];
			}
			sort(c + 1, c + j - i + 1 + 1);
			if((j - i + 1) % 2 == 1) {
				maxn = max(maxn, c[(j - i + 1) / 2]);
			}
			else {
				maxn = max(maxn, (c[(j - i + 1) / 2] + c[(j - i + 1) / 2 + 1]) / 2);
			}
		}
	}
	cout << maxn;
    return 0;
}