cses

solution to cses exercise problems
git clone git://git.superpozycja.net/cses
Log | Files | Refs | README

commit 9332fdbfec0299adb4eaa88242c29de6f846b863
parent a5490ce98ab84872a4f9c4a6369c7f49353ca068
Author: superpozycja <anna@superpozycja.net>
Date:   Sun, 27 Oct 2024 14:28:45 +0100

solve restaurant customers

Diffstat:
Asorting_and_searching/restaurant_customers.cpp | 44++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+), 0 deletions(-)

diff --git a/sorting_and_searching/restaurant_customers.cpp b/sorting_and_searching/restaurant_customers.cpp @@ -0,0 +1,44 @@ +#include <bits/stdc++.h> + +using namespace std; + +using ui = unsigned int; +using l = long; +using ul = unsigned long; +using ll = long long; +using ull = unsigned long long; + +using vi = vector<int>; +using vui = vector<ui>; +using vl = vector<l>; +using vul = vector<ul>; +using vll = vector<ll>; +using vull = vector<ull>; + +void solve() +{ + int n; + cin >> n; + vector<pair<int, int>> c; + for (int i = 0; i < n; i++) { + int s, e; + cin >> s >> e; + c.push_back({s, 1}); + c.push_back({e, -1}); + } + sort(c.begin(), c.end()); + int cur = 0; + int res = 0; + for (auto x : c) { + cur += x.second; + res = cur > res ? cur : res; + } + cout << res << "\n"; +} + +int main() +{ + ios::sync_with_stdio(0); + cin.tie(0); + solve(); +}