Popcorn
시간 제한2초메모리 제한1024 MB
고른 조리 시간들 중 하나가 구간 [A_i, B_i)에 들어가는 팝콘 종류의 양의 합이 최대가 되도록 M개 이하의 시간을 고르는 문제이다.
문제
We all know that popcorn is a culinary delicacy. While you were preparing for this year's selection camp (and the after parties), you ordered types of microwave popcorn. For each different type you know values:
- = the time (in seconds) when the popcorn of type pops
- = the time (in seconds) then the popcorn of type gets burned
- = the quantity of popcorn of type
You also have disposable popcorn bags of large capacity (practically, infinite) and a microwave oven. As, of course, no one likes burned or unpopped popcorn, you wish to partition it in the bags and then put those in the oven, setting a certain cooking time , such that in the end you'll have as much edible popcorn as possible.
Formally, the popcorn of type used in bag , which was cooked in the oven seconds, is edible if and only if .
Given types of popcorn and the number of available bags, you have to find a convenient partition and the cooking times for each bag, such that in the end you'll have as much edible popcorn as possible. Output the quantity of edible popcorn. Too simple!
입력
The first line contains two integers and .
Each of the next lines contains integers , , , corresponding to each popcorn type.
출력
Output a single integer representing the maximum quantity of edible popcorn you can get.
제한
- The total quantity of popcorn doesn't exceed
- Some bags can be left empty!
- Let