You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
656 B
C++

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
multiset<int> s;
int n, x;
char buf[20];
for (; ~scanf("%d", &n); putchar('\n'), s.clear())
for (int i = 0; i < n; i++)
if (scanf("%s%d", buf, &x), buf[1] == 'u')
s.insert(x);
else
{
auto ite = s.upper_bound(x);
if (ite != s.begin())
printf("%d\n", *--ite), s.erase(ite);
else
puts("No Element!");
}
return 0;
}