Submission
Status:
[-S][-S][-S][-S][-S][-S][-S][-S][-S][-S]
Subtask/Task Score:
{0/10}{0/10}{0/10}{0/10}{0/10}{0/10}{0/10}{0/10}{0/10}{0/10}
Score: 0
User: anonymous
Problemset: ลอดสะพาน
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-27 10:46:20
#include <bits/stdc++.h>
using namespace std;
struct build{
int c;
int t;
};
bool cmp(const build &a,const build &b){
if(a.c != b.c) return a.c < b.c;
return a.t > b.t;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int l,n; cin >> l >> n;
vector<build> ev;
ev.reserve(2 * n);
for(int i=0;i<n;i++){
int a,b; cin >> a >> b;
ev.push_back({a,1});
ev.push_back({b,-1});
}
sort(ev.begin(),ev.end(),cmp);
int ans =0,temp =0;
for(int i=0;i < ev.size();i++){
temp += ev[i].t;
if((i == ev.size() - 1 || ev[i].c < ev[i+1].c) && temp > ans) ans == temp;
}
cout << ans;
}