weCryOPEN

ECOO '19 R1 P1 - Free Shirts

Feb 26th, 2020
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. for _ in range(10):
  2.     n, m, d = map(int, input().split())
  3.     events = [int(a) for a in input().split()]
  4.    
  5.     # Amount of shirts he has in total, dirty or clean.
  6.     num_shirts = n
  7.    
  8.     # Number of days he had to do the laundry.
  9.     laundry = 0
  10.    
  11.     for day in range(1, d + 1):        
  12.         if n == 0:
  13.             # He does the laundry, so we refresh the amount of shirts
  14.             # and increment the laundry variable.
  15.             n = num_shirts
  16.             laundry += 1
  17.            
  18.         # He wore a shirt, so decrement from the amount of clean shirts.
  19.         n -= 1
  20.            
  21.         # Multiple events can occur in one day.
  22.         # This works because if the day is not in events, it'll return 0
  23.         # anyways. Adding 0 to num_shirts won't change its value.
  24.         events_today = events.count(day)
  25.         num_shirts += events_today
  26.         n += events_today
  27.        
  28.     print(laundry)
Add Comment
Please, Sign In to add comment