TLE 63分求助
查看原帖
TLE 63分求助
1003284
封禁用户楼主2023/9/4 16:05
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
multiset<int> st;
signed main() {
	int n;
	cin >> n;
	int op, x;
	while (n--) {
		scanf("%d%d",&op,&x);
		if (op == 1) {
			st.insert(x);
		} else if (op == 2) {
			auto it = st.find(x);
			st.erase(it);
		} else if (op == 3) {
			cout << distance(st.begin(), st.lower_bound(x)) + 1 << endl;
		} else if (op == 4) {
			auto it = st.begin();
			advance(it, x - 1);
			printf("%d\n",*it);
		} else if (op == 5) {
			auto it = st.lower_bound(x);
			it--;
			printf("%d\n",*it);
		} else if (op == 6) {
			auto it = st.upper_bound(x);
			printf("%d\n",*it);
		}
	}
}

2023/9/4 16:05
加载中...