Primeiro Problema de Line Sweep (que eu sei que é entitulado como isso né)
This commit is contained in:
parent
162943a922
commit
7ad7a196f1
34
Problems/NepsAcademy/neps_1746.cpp
Normal file
34
Problems/NepsAcademy/neps_1746.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
ios::sync_with_stdio(false);
|
||||||
|
|
||||||
|
int n, counter=0, maxc = 0;
|
||||||
|
long long x,y;
|
||||||
|
vector <pair<long long, int>> eventos;
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
eventos.resize(2*n);
|
||||||
|
for(int i = 0; i < 2*n; i+= 2){
|
||||||
|
cin >> x >> y;
|
||||||
|
eventos[i] = {x,1};
|
||||||
|
eventos[i+1] = {x+y,0};
|
||||||
|
}
|
||||||
|
sort(eventos.begin(), eventos.end());
|
||||||
|
|
||||||
|
for(int i = 0; i < 2*n; i++){
|
||||||
|
if(eventos[i].second == 1){
|
||||||
|
counter++;
|
||||||
|
}else{
|
||||||
|
counter--;
|
||||||
|
}
|
||||||
|
|
||||||
|
maxc = max(maxc, counter);
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << maxc << '\n';
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
Problems/NepsAcademy/out
Executable file
BIN
Problems/NepsAcademy/out
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user