Primeiro Problema de Line Sweep (que eu sei que é entitulado como isso né)

This commit is contained in:
Daneck1988 2024-09-23 16:10:21 -03:00
parent 162943a922
commit 7ad7a196f1
2 changed files with 34 additions and 0 deletions

View 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

Binary file not shown.