-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccc21s3.py
27 lines (22 loc) · 916 Bytes
/
ccc21s3.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
# CCC '21 S3 - Lunch Concert
def output(s, end = False, highlight=False, index=""):
pass
# ************************ MUST REMOVE BEFORE SUMMIT ************************
from ccc import make_io
input, output = make_io(__file__, "tc2")
# ***************************************************************************
persons_cnt = int(input())
persons = [tuple([int(p) for p in input().split(" ")]) for i in range(0, persons_cnt)]
min_pos = min(persons, key=lambda p: p[0])[0]
max_pos = max(persons, key=lambda p: p[0])[0]
min_time = 0
opti_concert_pos = -1
for concert_pos in range(min_pos, max_pos):
concert_time = 0
for pos, speed, scope in persons:
concert_time += speed * (abs(pos - concert_pos) - scope)
output("%d -> %d" % (concert_pos, concert_time))
if min_time == 0 or concert_time < min_time:
min_time = concert_time
opti_concert_pos = concert_pos
print(min_time)