25 pts求调
查看原帖
25 pts求调
1398636
yezhengjie0000001楼主2025/7/22 22:00
#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
ll n;
ll x[1000010];
ll s[1000010];
ll hh=1,tt=0;
ll k;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>x[i];
		while(hh<=tt&&s[tt]+k<=i){
			hh++;
		}
		while(hh<=tt&&x[s[tt]]<=x[i]){
			tt--;
		}
		s[++tt]=i;
		if(i>=k){
			cout<<tt-hh+1<<'\n';
		}
	}
	return 0;
}
2025/7/22 22:00
加载中...