Advertisement
Farz0l1x

Untitled

May 1st, 2024
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. file = open('2.txt')
  2. N, L, M = map(int, file.readline().split())
  3. a = []
  4. for i in range(N):
  5.     st, r, t = file.readline().split()
  6.     a.append((int(st), int(st) + int(r), t))
  7. a.sort()
  8. park = [0] * (L + M)
  9. bus = 0
  10. left = 0
  11. for i in range(N):
  12.     st, end, t = a[i]
  13.     if t == "A":
  14.         for j in range(L + M):
  15.             if park[j] <= st:
  16.                 park[j] = end
  17.                 break
  18.         else:
  19.             left += 1
  20.     if t == 'B':
  21.         for j in range(L, L + M):
  22.             if park[j] <= st:
  23.                 park[j] = end
  24.                 bus += 1
  25.                 break
  26.         else:
  27.             left += 1
  28. print(bus, left)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement