-
Notifications
You must be signed in to change notification settings - Fork 4
/
Warm Reception.cpp
71 lines (62 loc) · 1.92 KB
/
Warm Reception.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
PROBLEM:
There is only one beauty parlour in the town CodingNinjasLand. The receptionist at the beauty parlor is flooded with appointment requests because the “Hakori” festival is round the corner and everyone wants to look good on it.
She needs your help. The problem is they don’t have chairs in reception. They are ordering chairs from NinjasKart. They don’t want to order more than required. You have to tell the minimum number of chairs required such that none of the customers has to stand.
Input Format :
First line contains the number of customers that will come. Second line contains N space-separated integers which represent the arrival timings of the customer. Third line contains N space-separated integers which represent the departure timings of the customer. Arrival and departure timings are given in 24-hour clock.
Constraints:
1<= N <= 100
Arrival and departure timings lie in the range [0000 to 2359]
Time Limit: 1 second
Output Format :
You have to print the minimum number of chairs required such that no customer has to wait standing.
Sample Test Cases:
Sample Input 1 :
5
900 1000 1100 1030 1600
1900 1300 1130 1130 1800
Sample Output 1:
4
Explanation:
4 because at 1100 hours, we will have maximum number of customers at the shop, throughout the day. And that maximum number is 4.
CODE:
*/
#include<bits/stdc++.h>
using namespace std;
struct interval{
long st;
long et;
};
int main() {
long t;
cin>>t;
long counter = 0;
interval ar[t];
for(long i = 0;i<t;i++){
cin>>ar[i].st;
}
for(long i = 0;i<t;i++){
cin>>ar[i].et;
}
long max = 0;
for(long i = 0;i<2400;i++){
for(long j = 0;j<t;j++){
if(i==ar[j].st){
counter++;
if(max<counter){
max = counter;
}
}
}
for(long j = 0;j<t;j++){
if(i==ar[j].et){
counter--;
if(max<counter){
max = counter;
}
}
}
}
cout<<max;
return 0;
}