STL样例过全WA求调
查看原帖
STL样例过全WA求调
727008
lwx20211103楼主2022/10/23 19:44
#include <bits/stdc++.h>//stupid windows,stupid dev-c++
using namespace std;//I love linux!

multiset<int> m;

int main()
{
	int q, p = 0;
	cin >> q;
	int i;
	m.insert(-2147483647);
	m.insert(2147483647);
	for (i = 0;i < q;i++)
	{
		int op, x;
		cin >> op >> x;
		if (op == 5)
		{
			m.insert(x);
		}
		else if (op == 1)
		{
			auto it = m.lower_bound(x);
			p = 0;
			for (auto i = m.begin();i != it;i++)
			{
				p++;
			}
			cout << p << "\n";
		}
		else if (op == 2)
		{
			p = -1;
			for (auto i:m)
			{
				if (++p == x)
				{
					cout << 1 << "\n";
				}
			}
		}
		else if (op == 3)
		{
			auto it = m.lower_bound(x);
			cout << *it-- << "\n";
		}
		else if (op == 4)
		{
			cout << *m.upper_bound(x) << "\n";
		}
	}
	return 0;
}

2022/10/23 19:44
加载中...