blob: 8d97e96a7a3a73fdd4e411a4a95c0cb23eeb9d79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
int main() {
size_t n;
std::cin >> n;
std::vector<std::pair<int, int>> c(n);
for (size_t i = 0; i < n; i++) {
int a, b;
std::cin >> a >> b;
c[i] = {a, b};
}
std::sort(c.begin(), c.end());
std::priority_queue<int, std::vector<int>, std::greater<int>> q;
size_t m{0};
for (auto d : c) {
while (!q.empty() && q.top() < d.first) q.pop();
q.push(d.second);
m = std::max(m, q.size());
}
std::cout << m << "\n";
}
|