求条
查看原帖
求条
491542
fedoralxy楼主2024/4/9 18:07
#include<bits/stdc++.h>
using namespace std;
multiset<int>s;
int t,tmp;
int main()
{
	s.insert(-0x7fffffff);
	s.insert(0x7fffffff);
	cin>>t;
	while(t--){
		int opt,x;
		cin>>opt>>x;
		if(opt==1)
		{
			auto it=s.lower_bound(x);
			tmp=0;
			for(auto i=s.begin();i!=it;i++,tmp++){
				printf("%d\n",tmp);
			}
		}
		else if(opt==2)
		{
			tmp=-1;
			for(int i:s){
				if(++tmp==x)printf("%d\n",i);
			}
		}
		else if(opt==3)
		{
			auto it=s.lower_bound(x);
			printf("%d\n",*--it);
		}
		else if(opt==4)printf("%d\n",*s.upper_bound(x));
		else s.insert(x);
	}
	return 0;
}

懒人 set 做法求条。

2024/4/9 18:07
加载中...