forked from Google-Developer-Student-Club-CCOEW/Competitive-Programming-2023-GDSC-CUMMINS-X-GDSC-MMCOE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Restaurant Customers Google-Developer-Student-Club-CCOEW#143
- Loading branch information
1 parent
5b8a315
commit 132bf6a
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
n = int(input()) | ||
events = [] # Create a list to store customer events (arrival, departure) | ||
for _ in range(n): | ||
a, b = map(int, input().split()) | ||
events.append((a, 1)) # Arrival event | ||
events.append((b, -1)) # Departure event | ||
|
||
# Sort the events by time | ||
events.sort() | ||
|
||
max_customers = 0 # Initialize the maximum number of customers | ||
current_customers = 0 # Initialize the number of customers currently in the restaurant | ||
|
||
for _, event_type in events: | ||
current_customers += event_type # Update the number of customers | ||
max_customers = max(max_customers, current_customers) | ||
|
||
print(max_customers) |