Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #26 https://kpolyakov.spb.ru/school/ege/gen.php?action=viewVar&answers=on&varId=3
- data = open('26.txt').readlines()
- n = int(data[0])
- a = []
- sr = 0
- for e in data[1:]:
- x, y, z = map(int, e.split())
- y += sr
- a.append((x,y,z))
- sr = sr // len(a)
- dr = []
- for i in range(len(a)):
- if a[i][1] > sr:
- dr.append(a[i])
- ost = {}
- prod = {}
- for e in dr:
- if e[0] not in ost:
- ost[e[0]] = 0
- prod[e[0]] = 0
- ost[e[0]] += e[2]
- prod[e[0]] += e[2] ^ 1
- all_lid = (0, 0, 0) #prod, cost, -ost
- art = -1
- for e in dr:
- if (prod[e[0]], e[1], -ost[e[0]]) > all_lid:
- all_lid = (prod[e[0]], e[1], -ost[e[0]])
- art = e[0]
- print(-all_lid[2] * all_lid[1], art)
Advertisement
Add Comment
Please, Sign In to add comment