int input ost 120 ch1 ch2 smax for in range int input 120 if or 60 if

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
n = int(input())
ost = [0] * 120
ch1 = 0
ch2 = 0
smax = 0
for i in range(n):
a = int(input()); b = a%120
if b == 0 or b == 60:
if a < ost[b] and smax < a + ost[b]:
smax = a + ost[b]
ch1 = ost[b]; ch2 = a
else: ost[b] = a
else:
if ost[-b] > a > ost[b] and a + ost[-b] > smax:
ost[b] = a
smax = ost[-b] + a
ch1 = ost[-b]; ch2 = a
elif a > ost[b]: ost[b] = a
print(ch1, ch2)