You are viewing a single comment's thread. Return to all comments →
any comments on to improve this pthon code to use greedy algorithm I time out for the later cases. Thanks
N, M = map(int,raw_input().split()) lst = [0]*N
for _ in range(M): a, b, k = [int(n) for n in raw_input().split(" ")]
for i in range(a-1,b): lst[i] += k
print max(lst)
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
any comments on to improve this pthon code to use greedy algorithm I time out for the later cases. Thanks
N, M = map(int,raw_input().split()) lst = [0]*N
for _ in range(M): a, b, k = [int(n) for n in raw_input().split(" ")]
print max(lst)