• + 2 comments

    A generator doesn't buy anything. Test 7 - end still fail due to timeout.

    This will do the same thing and still fail due to timeout.

    N, M = [ int(input) for input in  raw_input().strip().split() ]
    arr = [0] * N
    for _ in range( M ):
        a, b, k = [ int(input) for input in  raw_input().strip().split() ]
        for x in xrange( a-1, b ):
            arr[x] +=k 
    print max( arr )
    

    Implementing the C++ solution from the top level comment in Python 2.7 can be done as this ( changing out a few bits that don't make sense ):

    N, M = [int(n) for n in raw_input().split()]
    arr = [0]*N
    for _ in range( M ):
        a, b, k = [int(n) for n in raw_input().split() ]
        arr[a-1] += k
        if b <= ( N - 1 ):
            arr[b] -= k
    my_max = x = 0
    for i in range( N ):
        x += arr[i]
        if my_max < x:
            my_max = x
    print( my_max )