From 96254947699986c59f0dc63d69fd4b76bd3ed43e Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 6 Jul 2026 19:08:08 +0200 Subject: Initial commit --- .../restaurant_customers_1619.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 02_sorting_and_searching/restaurant_customers_1619.cpp (limited to '02_sorting_and_searching/restaurant_customers_1619.cpp') 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 @@ +#include +#include +#include +#include + +int main() { + size_t n; + std::cin >> n; + std::vector> 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, std::greater> 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"; +} -- cgit v1.3