-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cpp
38 lines (36 loc) · 819 Bytes
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
char a[4];
// string a;
vector<int> pq;
int main()
{
// int n1=3;
pq.push_back(0);
// int index = 0;
while (scanf("%s", a) != EOF)
{
int index;
if (a[1] == 'u')
{
int n;
scanf("%d", &n);
index = lower_bound(pq.begin(), pq.end(), n) - pq.begin();
// cout<<index<<endl;
pq.insert(pq.begin() + index, n);
// index++;
}
else
{
// for (int i : pq)
// cout << i << ' ';
// cout << endl;
int dl = (pq.size()) / 2;
// cout << pq[dl] << endl;
printf("%d\n", pq[dl]);
pq.erase(pq.begin() + dl);
}
}
}