求助!!
查看原帖
求助!!
751073
wuxiyi楼主2022/12/30 12:12
#include<iostream>
using namespace std;
struct node{
	int pos,b;
};
int n,m;
node tmp;
node a[4000009];
int head=1,tail=0;
int main()
{
	//freopen("P1440_2.in","r",stdin);
	//freopen("tmp.out","w",stdout);
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		printf("%d\n",a[head].b);
		scanf("%d",&tmp.b);
		tmp.pos=i;
		while (head<=tail&&a[tail].b>=tmp.b)
		{
			tail--;
		}
		while (a[head].pos<=i-m)
		{
			head++;
		}
		tail++;
		a[tail].b=tmp.b;
		a[tail].pos=tmp.pos;
	}
	return 0;
}

https://www.luogu.com.cn/record/98258771

TLE*2

RE*1

WA*1

2022/12/30 12:12
加载中...