求助,不O2最后一个点卡住88分
查看原帖
求助,不O2最后一个点卡住88分
332619
NaoNao666楼主2022/3/12 22:45

rt

#include<iostream>
#include<cstdio>
#include<queue>
#include<stack>
using namespace std;
int x,m,n;
priority_queue<int> q;
stack<int> p;
int main() {
	scanf("%d%d",&n,&m);
	while(n--){
		scanf("%d",&x);
		q.push(x);
		if(q.size()<=m) continue;
		q.pop();
	}
	while(!q.empty()){
		p.push(q.top());
		q.pop();
	}
	while(!p.empty()){
		printf("%d\n",p.top());
		p.pop();
	}
	return 0;
}
2022/3/12 22:45
加载中...