-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbee1245.cpp
More file actions
46 lines (40 loc) · 815 Bytes
/
Copy pathbee1245.cpp
File metadata and controls
46 lines (40 loc) · 815 Bytes
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
39
40
41
42
43
44
45
46
/**
* Contest : Beecrowd
* Problem : 1245 - Botas Perdidas
* Link : https://judge.beecrowd.com/pt/problems/view/1245
* Time : O(N * logN)
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
int main() {
fastio
int n;
while (cin >> n) {
multiset<int> esq, dir;
int cnt = 0;
while (n--) {
int m; char l;
cin >> m >> l;
if (l == 'E') {
if (dir.count(m)) {
cnt++;
dir.erase(dir.find(m)); //logN
}
else
esq.insert(m); // logN
}
else { // l == 'D'
if (esq.count(m)) {
cnt++;
esq.erase(esq.find(m));
}
else
dir.insert(m);
}
}
cout << cnt << '\n';
}
return 0;
}