Skip to content

Commit

Permalink
Create Restaurant Customers Google-Developer-Student-Club-CCOEW#143
Browse files Browse the repository at this point in the history
  • Loading branch information
vaishnavim141003 authored Oct 31, 2023
1 parent 5b8a315 commit 132bf6a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Restaurant Customers #143
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)

0 comments on commit 132bf6a

Please sign in to comment.