TLE90求助
  • 板块P2251 质量检测
  • 楼主hayoon
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/12/4 20:04
  • 上次更新2023/12/4 22:28:27
查看原帖
TLE90求助
915383
hayoon楼主2023/12/4 20:04
#include<bits/stdc++.h>
using namespace std;
int sa[1000000];
int sb[1000000];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	scanf("%d",&sa[i]);
	priority_queue<int,vector<int>,greater<int> > q;
	priority_queue<int,vector<int>,greater<int> > p;
	for(int i=1;i<=m;i++)
	q.push(sa[i]);
	printf("%d\n",q.top());
	for(int i=2;i<=n-m+1;i++)
	{
		q.push(sa[i+m-1]);
		p.push(sa[i-1]);
		while(q.top()==p.top())
		{
			q.pop();
			p.pop();
		}
		printf("%d\n",q.top());
	}
	return 0;
}
2023/12/4 20:04
加载中...