You are viewing a single comment's thread. Return to all comments →
A Python 3 solution in O(M) time and space, solely independent of N. :)
from itertools import accumulate from collections import defaultdict ar = defaultdict(int) for _ in range(int(input().split()[1])): p, q, k = map(int, input().split()) ar[p] += k ar[q + 1] -= k print(max(accumulate(ar[i] for i in sorted(ar))))
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 →
A Python 3 solution in O(M) time and space, solely independent of N. :)