nq1s788

26 найти лидера продаж

May 4th, 2025
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. #26 https://kpolyakov.spb.ru/school/ege/gen.php?action=viewVar&answers=on&varId=3
  2. data = open('26.txt').readlines()
  3. n = int(data[0])
  4. a = []
  5. sr = 0
  6. for e in data[1:]:
  7.     x, y, z = map(int, e.split())
  8.     y += sr
  9.     a.append((x,y,z))
  10. sr = sr // len(a)
  11. dr = []
  12. for i in range(len(a)):
  13.     if a[i][1] > sr:
  14.         dr.append(a[i])
  15. ost = {}
  16. prod = {}
  17. for e in dr:
  18.     if e[0] not in ost:
  19.         ost[e[0]] = 0
  20.         prod[e[0]] = 0
  21.     ost[e[0]] += e[2]
  22.     prod[e[0]] += e[2] ^ 1
  23. all_lid = (0, 0, 0) #prod, cost, -ost
  24. art = -1
  25. for e in dr:
  26.     if (prod[e[0]], e[1], -ost[e[0]]) > all_lid:
  27.         all_lid = (prod[e[0]], e[1], -ost[e[0]])
  28.         art = e[0]
  29. print(-all_lid[2] * all_lid[1], art)
Advertisement
Add Comment
Please, Sign In to add comment