-
Notifications
You must be signed in to change notification settings - Fork 1
/
B.py
31 lines (23 loc) · 1.13 KB
/
B.py
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
n = int(input())
# Важно два события - момент прибытия и момент окончания досмотра груза.
# Будем рассчитывать момент окончания отсмотра груза как сумму момента прибытия и времени его обработки
# Код события прибытия груза: 1, окончания обработки: -1. Исходим из того, что при наличии двух разных событий в
# один момент времени завершается обработка текущего груза, и начинается обработка следующего (дополнительный аппарат
# не требуется).
events = [(0, 0)] * (2 * n)
j = 0
for i in range(n):
t_i, l_i = map(int, input().split())
events[j] = (t_i, 1)
events[j + 1] = (t_i + l_i, -1)
j += 2
events.sort()
cur_load = 0
max_load = 0
for event in events:
if event[1] == -1:
cur_load -= 1
else:
cur_load += 1
max_load = max(cur_load, max_load)
print(max_load)