哪里出问题了?
  • 板块P2032 扫描
  • 楼主Never_AC
  • 当前回复5
  • 已保存回复5
  • 发布时间2023/8/20 09:11
  • 上次更新2023/11/3 02:32:24
查看原帖
哪里出问题了?
546290
Never_AC楼主2023/8/20 09:11

下载了第一个数据点,输出一模一样。为什么 WA ?QwQ

#include<bits/stdc++.h>
using namespace std;
struct cxk{
	int zhi,wei;
bool operator < (const cxk&b) const
{
	return zhi < b.zhi;
}
};
int n,k;
priority_queue<cxk> q;
cxk op,ba;
int a[1000005];
int main(){
	cin>>n>>k;
	for(int i=1,x;i<=k;i++){
		cin>>x;
		a[i]=x;
		op.zhi=x;
		op.wei=i;
		q.push(op);
	}
	ba=q.top();
		cout<<ba.zhi<<endl;
	for(int i=1,l=1;i<=n-k;i++,l++){
		int y;
		ba=q.top();
		op.wei=k+i;
		cin>>y;
		op.zhi=y;
		q.push(op);
		if(ba.wei<i+1||ba.wei>i+k)  q.pop();
		ba=q.top();
		cout<<ba.zhi<<endl;
	}
	return 0;
}
2023/8/20 09:11
加载中...