luoguP2032 扫描

思路

一道超级水的套壳魔板题

代码

#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
const int N=2e6+6;
int a[N];
int n,k;
priority_queue< pair<int,int> >q;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		q.push(make_pair(a[i],i));
		if(i>=k){
			while(q.top().second<=i-k) q.pop();
			printf("%d\n",q.top().first);
		}
	}
	return 0;
}
posted @ 2024-07-23 10:02  mcr130102  阅读(1)  评论(0编辑  收藏  举报
请不要抄袭任何人的博客,这是对一名开发者最基本的尊重。