-
-
Save Hacv16/21042c89bfd55f30365f9d6e71b60207 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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