- Notifications
You must be signed in to change notification settings - Fork 366
/
Copy pathRestaurant.cc
25 lines (21 loc) · 603 Bytes
/
Restaurant.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include"bits/stdc++.h"
#defineintlonglong
usingnamespace::std;
signedmain(){
ios_base::sync_with_stdio(false),cin.tie(nullptr);
int n; cin >> n;
vector<pair<int,int>> v;
for (int i = 0; i < n; ++i) {
int start, end; cin >> start >> end;
v.push_back({start,+1});
v.push_back({end,-1});
}
sort(v.begin(),v.end());
vector<int> prefix(v.size()+1);
prefix[0] = v[0].second;
for (int i = 1; i < v.size(); ++i) {
prefix[i] = prefix[i-1] + v[i].second;
}
cout << *max_element(prefix.begin(),prefix.end()) << endl;
return0;
}