MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

CSES/Sorting/Restaurant.cc:5–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3using namespace::std;
4
5signed main(){
6 ios_base::sync_with_stdio(false),cin.tie(nullptr);
7
8 int n; cin >> n;
9 vector<pair<int,int>> v;
10 for (int i = 0; i < n; ++i) {
11 int start, end; cin >> start >> end;
12 v.push_back({start,+1});
13 v.push_back({end,-1});
14 }
15 sort(v.begin(),v.end());
16 vector<int> prefix(v.size()+1);
17 prefix[0] = v[0].second;
18 for (int i = 1; i < v.size(); ++i) {
19 prefix[i] = prefix[i-1] + v[i].second;
20 }
21 cout << *max_element(prefix.begin(),prefix.end()) << endl;
22 return 0;
23}
24
25

Callers

nothing calls this directly

Calls 2

push_backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected