Skip to content

Instantly share code, notes, and snippets.

@Hacv16

Hacv16/hotel.cpp Secret

Last active March 16, 2024 13:57
Show Gist options
  • Save Hacv16/21042c89bfd55f30365f9d6e71b60207 to your computer and use it in GitHub Desktop.
Save Hacv16/21042c89bfd55f30365f9d6e71b60207 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n; cin >> n;
vector<pair<int, int>> eventos;
for(int i = 1; i <= n; i++)
{
int s, e; cin >> s >> e;
// Crio os eventos da sweep
eventos.emplace_back(s, 1);
eventos.emplace_back(e, 2);
}
sort(eventos.begin(), eventos.end());
int hospedes = 0, resp = 0;
// "Sweep"
for(auto [tempo, tipo] : eventos)
{
if(tipo == 1) hospedes++;
else if(tipo == 2) hospedes--;
resp = max(resp, hospedes);
}
cout << resp << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment