Advertisement
nq1s788

22

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