Submission

Status:

[PP][PP][PP][PP][PP][PP][PP][PP][PP][PP]

Subtask/Task Score:

{10/10}{10/10}{10/10}{10/10}{10/10}{10/10}{10/10}{10/10}{10/10}{10/10}

Score: 100

User: Bestzu

Problemset: ลอดสะพาน

Language: cpp

Time: 0.003 second

Submitted On: 2025-10-17 11:04:11

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;


void display(vector<int> &a) {
	for(auto &e : a) {
		cout << e << " ";
	}
	cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

	int l; cin >> l;
    int n; cin >> n;
    
    vector<pair<int,int>> a;
    for(int i = 0; i < n; i++) {
    	int l, r; cin >> l >> r;
    	a.push_back({l, 1});
    	a.push_back({r, -1});
	}
	sort(a.begin(), a.end());
	
	int mx = 0, cur = 0;
	for(int i = 0; i < n+n; i++) {
		cur += a[i].second;
		mx = max(mx, cur);
	}
	cout << mx << endl;
    return 0;
}