模拟
2024-05-24 16:36:13
发布于:上海
14阅读
0回复
0点赞
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n,k,m;
cin>>n>>k>>m;
int broken_lamp[1000000]={};
bool is_broken[1000000]={};
for(int i=0;i<m;i++){
cin>>broken_lamp[i];
is_broken[broken_lamp[i]-1]=1;
}int longest_light=0,index=0;
for(int i=0;i<=n-k;i++){
int bright=count(is_broken+i,is_broken+i+k,0);
if(bright>longest_light)longest_light=bright,index=i;
}cout<<count(is_broken+index,is_broken+index+k,1);
return 0;
}
这里空空如也
有帮助,赞一个