Skip to content

Commit

Permalink
restcust
Browse files Browse the repository at this point in the history
  • Loading branch information
megargayu committed Oct 15, 2022
1 parent cb834ca commit 2eda409
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions cses/sortingsearching/restcust/restcust.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// https://cses.fi/problemset/task/1619

#include <bits/stdc++.h>
using namespace std;

#define MAX_N 2e5

vector<pair<int, bool>> poi(MAX_N * 2);

int main()
{
int N;
cin >> N;

int a, b;
for (int i = 0; i < N; ++i)
{
cin >> a >> b;
poi[i * 2] = {a, true};
poi[i * 2 + 1] = {b, false};
}

sort(poi.begin(), poi.begin() + N * 2, [](const auto &a, const auto &b)
{ return a.first < b.first; });

int ans = 0, curr = 0;
for (int i = 0; i < N * 2; ++i)
{
curr += poi[i].second ? 1 : -1;
ans = max(ans, curr);
}

cout << ans << '\n';

return 0;
}

0 comments on commit 2eda409

Please sign in to comment.