求助,全WA
查看原帖
求助,全WA
757409
Flying_Eagle楼主2023/3/29 20:08
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
multiset<int> st;
int n;
int op, x;

int main() {
//	freopen("xxxx.in", "r", stdin);
//	freopen("xxxx.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> op >> x;
		if (op == 1) {
			auto it = st.lower_bound(x);
			int tmp = 1;
			for (auto i = st.begin(); i != it; i++)
				tmp++;
			cout << tmp << endl;
		} else if (op == 2) {
			int tmp = 1;
			for (auto it = st.begin(); it != st.end(); it++) {
				if (tmp == x) {
					cout << *it << endl;
					break;
				}
				tmp++;
			}
		} else if (op == 3) {
			if (!st.count(x)) {
				cout << "-2147483647" << endl;
				continue;
			}
			auto it = st.lower_bound(x);
			cout << *(--it) << endl;
		} else if (op == 4) {
			if (!st.count(x)) {
				cout << "2147483647" << endl;
				continue;
			}
			for (auto it = st.begin(); it != st.end(); it++) {
				if (*it == x) {
					cout << *(++it) << endl;
					break;
				}
			}
		} else if (op == 5) {
			st.insert(x);
		}
	}
	return 0;
}

2023/3/29 20:08
加载中...