比赛 |
EYOI与SBOI开学欢乐赛6th |
评测结果 |
AAAAAAAAAA |
题目名称 |
IOI2099 |
最终得分 |
100 |
用户昵称 |
yrtiop |
运行时间 |
0.108 s |
代码语言 |
C++ |
内存使用 |
2.06 MiB |
提交时间 |
2022-09-19 19:27:23 |
显示代码纯文本
#include <bits/stdc++.h>
const int maxn = 1e5 + 5;
int n,k,a[maxn],sum[maxn],suf[maxn];
bool check(int x) {
sum[0] = 0;
for(int i = 1;i <= n;++ i)sum[i] = sum[i - 1] + (a[i] >= x ? 1 : -1);
suf[n + 1] = -n;
for(int i = n;i;-- i)suf[i] = std::max(suf[i + 1] , sum[i]);
for(int i = 0;i <= n - k;++ i) {
if(suf[i + k] - sum[i] > 0)return true;
}
return false;
}
int main() {
freopen("player.in","r",stdin);
freopen("player.out","w",stdout);
scanf("%d %d",&n,&k);
for(int i = 1;i <= n;++ i)scanf("%d",&a[i]);
int l = 0,r = 5e5;
while(l <= r) {
int mid = (l + r) >> 1;
if(check(mid))l = mid + 1;
else r = mid - 1;
}
printf("%d",r);
return 0;
}