结果显示
查看原帖
结果显示
1098507
zdnzkzl楼主2024/5/14 10:49

远程oj尚未返回编译信息,显示compile Error

#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		priority_queue<int,vector<int>,less<int> >maxx;//大根堆 
		priority_queue<int,vector<int>,greater<int> >minn;//小根堆 
		int n;
		while(scanf("%d",&n)&&n!=0)
		{
			if(n==-1)
			{
				printf("%d",maxx.top());
				puts(" ");
				maxx.pop();
			}
			else
			{
				if(maxx.empty()||n<=maxx.top())
				{
					maxx.push(n);
				}
				else
				{
					minn.push(n);
				}
				
				
			}
			/*维护对顶堆*/
			int size=(maxx.size()+minn.size()+1)/2;
			if(maxx.size()>size)
			{
				minn.push(maxx.top());
				maxx.pop();
			} 
			else if(maxx.size()<size)
			{
				maxx.push(minn.top());
				minn.pop();
			}
		}
		
		
	}
	return 0;
} 
2024/5/14 10:49
加载中...