Created
August 27, 2023 02:19
-
-
Save estelabn/fe3ec6d5a4797874772d9b164317b26e 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>> v; | |
for(int i=0; i<n; i++){ | |
int c,p; | |
cin >> c >> p; | |
v.push_back({c,1}); | |
v.push_back({p,-1}); | |
} | |
sort(v.begin(), v.end()); | |
int qnt = 0, maxQnt = 0, instanteAnterior = -1; | |
for(int i = 0; i<v.size(); i++){ | |
int instante = v[i].first, valor = v[i].second; | |
if(instanteAnterior != instante) maxQnt = max(maxQnt, qnt); | |
qnt += valor; | |
instanteAnterior = instante; | |
} | |
maxQnt = max(qnt, maxQnt); | |
cout << maxQnt*20 << "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment