0分 求助 感谢好心的大佬
查看原帖
0分 求助 感谢好心的大佬
170047
小渣青999楼主2020/8/15 21:07
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
bool cmp(int x,int y)
{
	return x<y; 
}
vector<int> v;
int main()
{
	int n;scanf("%d",&n);
	while(n--)
	{
		int x,y;scanf("%d%d",&x,&y);
		if(x==1)	v.push_back(y);
		else
		{
			if(v.empty())
			{
				printf("Empty\n");
				continue;
			}
			sort(v.begin(),v.end(),cmp);
		
			if(*(v.end()-1)<y)
			{
				printf("%d\n",*(v.end()-1));
				v.erase(v.end()-1);
				continue;
			}
			int pos=upper_bound(v.begin(),v.end(),y)-v.begin();
			pos--;
			if(pos==-1) pos=0;
			printf("%d\n",v[pos]);
			v.erase(v.begin()+pos);
		}
	}
	return 0;
}
2020/8/15 21:07
加载中...