aboutsummaryrefslogtreecommitdiff
path: root/02_sorting_and_searching/restaurant_customers_1619.cpp
diff options
context:
space:
mode:
Diffstat (limited to '02_sorting_and_searching/restaurant_customers_1619.cpp')
-rw-r--r--02_sorting_and_searching/restaurant_customers_1619.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/02_sorting_and_searching/restaurant_customers_1619.cpp b/02_sorting_and_searching/restaurant_customers_1619.cpp
new file mode 100644
index 0000000..8d97e96
--- /dev/null
+++ b/02_sorting_and_searching/restaurant_customers_1619.cpp
@@ -0,0 +1,24 @@
1#include <algorithm>
2#include <iostream>
3#include <queue>
4#include <vector>
5
6int main() {
7 size_t n;
8 std::cin >> n;
9 std::vector<std::pair<int, int>> c(n);
10 for (size_t i = 0; i < n; i++) {
11 int a, b;
12 std::cin >> a >> b;
13 c[i] = {a, b};
14 }
15 std::sort(c.begin(), c.end());
16 std::priority_queue<int, std::vector<int>, std::greater<int>> q;
17 size_t m{0};
18 for (auto d : c) {
19 while (!q.empty() && q.top() < d.first) q.pop();
20 q.push(d.second);
21 m = std::max(m, q.size());
22 }
23 std::cout << m << "\n";
24}

Generated with cgit - Back to sebastiano.tronto.net