#P1833. 樱花
樱花
Description
Ai Yu Chou has planted cherry blossom trees in the backyard, each with an aesthetic value (). Every morning before school, Ai Yu Chou enjoys the blossoms. As a biology ace, he knows how to appreciate them: each tree can be viewed at most times, where means unlimited views; otherwise, at most times. Viewing tree once takes minutes (). Only a short time remains before he must leave for school. Determine which trees to view (and how many times) to maximize the total aesthetic value while ensuring he can leave on time (or earlier).
Input Format
There are lines.
Line 1: current time (hour:minute), school departure time (hour:minute), and the number of trees . The formats of , are hh:mm, where , , and is a positive integer.
Lines to : three positive integers per line: the time to view tree once , the aesthetic value of tree , and the allowed view count ( means unlimited; otherwise, at most times).
Output Format
Output a single integer, the maximum total aesthetic value.
6:50 7:00 3
2 1 0
3 3 1
4 5 4
11
Hint
Constraints: For of the testdata, (i.e., the time from start to end does not exceed minutes), and . It is guaranteed that and are within the same day.
Sample explanation: view the first tree once, and the third tree times.
Translated by ChatGPT 5
京公网安备 11011102002149号