Skip to content

Instantly share code, notes, and snippets.

@IKKO-Ohta
Created July 5, 2017 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IKKO-Ohta/be9099a23a78b043b3be28e208730fa0 to your computer and use it in GitHub Desktop.
Save IKKO-Ohta/be9099a23a78b043b3be28e208730fa0 to your computer and use it in GitHub Desktop.
# coding: utf-8
nums = [int(x) for x in input().split()]
N,M = nums[0],nums[1]
imos = [0 for i in range(100003)]
V = 0
for i in range(N):
nums = [int(x) for x in input().split()]
a,b,v = nums[0],nums[1],nums[2]
V += v
imos[a] += v
imos[b+1] -= v
ans = []
j = 0
for i in imos:
ans.append(j+i)
j += i
print(V-min(ans[1:M+1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment