Advertisement
nq1s788

22(id не с 1)

May 18th, 2024
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. #https://inf-ege.sdamgia.ru/problem?id=48443
  2. data = open('22 (4).csv').readlines()[1:]
  3. n = len(data)
  4. ids = {}
  5. tt = [0] * n
  6. prev = [[] for i in range(n)]
  7. for i in range(n):
  8.     ind, t, *args = data[i].split(';')[:-2]
  9.     ind = int(ind)
  10.     ids[ind] = i
  11.     t = int(t)
  12.     tt[i] = t
  13.     for e in args:
  14.         if e != '':
  15.             x = ids[int(e.replace('"', ''))]
  16.             prev[i].append(x)
  17. answ = [0] * n
  18. for i in range(n):
  19.     answ[i] = tt[i]
  20.     for lst in prev[i]:
  21.         answ[i] = max(answ[i], answ[lst] + 3 + tt[i])
  22. print(max(answ))
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement