-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path5.cpp
More file actions
56 lines (38 loc) · 925 Bytes
/
5.cpp
File metadata and controls
56 lines (38 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// You are given the arrival and leaving times of n customers in a restaurant.
// What was the maximum number of customers?
// Input
// The first input line has an integer n: the number of customers.
// After this, there are n lines that describe the customers. Each line has two integers a and b: the arrival and leaving times of a customer.
// You may assume that all arrival and leaving times are distinct.
// Output
// Print one integer: the maximum number of customers.
// Constraints
// 1≤n≤2⋅105
// 1≤a<b≤109
// Example
// Input:
// 3
// 5 8
// 2 4
// 3 9
// Output:
// 2
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,x,y;cin>>n;
map <int, int> m;
for (int i = 0; i < n; i++)
{
cin>>x>>y;
m[x]+=1;
m[y]+=-1;
}
int mx=0,sum=0;
for(auto it: m){
sum+=it.second;
mx=max(mx,sum);
}
cout<<mx;
}