#P9871. [NOIP2023] 天天爱打卡
[NOIP2023] 天天爱打卡
Problem Description
Student T is very enthusiastic about running. To make running more fun, he decides to create an app called Daily Check-in, so that users can check in for running every day.
After finishing development, student T plans to do a trial run, and he asks student Y to help. The trial run lasts for days, numbered from to .
For student Y, if he chooses to check in for running on some day, his energy value will decrease by . Initially, his energy value is , and during the trial run his energy value may be negative.
Also, student Y will not check in for running continuously for more than days; that is, there cannot exist such that he checked in for running from day to day .
Student T designed challenges in the app. The -th challenge () can be described by three positive integers , meaning that if on day the user has already checked in for running continuously for at least days (i.e. from day to day all days are checked in), then student T will treat the user to a meal, thereby increasing the user’s energy value by .
Now student Y wants to know: after the days of the trial run end, what is the maximum energy value he can reach?
Input Format
This problem’s test points contain multiple groups of testdata.
The first line contains two integers and , representing the test point ID and the number of testdata groups. For the samples, indicates that the sample has the same constraints as test point .
Next, for each group of testdata:
- The first line contains four positive integers , representing the number of trial days, the number of challenges, the limit on the maximum consecutive days that student Y can check in for a single running streak, and the energy decrease for each running check-in.
- The next lines each contain three positive integers , describing one challenge.
Output Format
Output one line with one integer, the answer for the corresponding testdata group.
1 1
3 2 2 1
2 2 4
3 2 3
2
Hint
[Sample Explanation #1]
Check in for running on days , do not check in on day , and in the end you will obtain an energy value of .
[Sample Explanation #2]
This sample satisfies the constraints of test point .
[Sample Explanation #3]
This sample satisfies the constraints of test point .
[Sample Explanation #4]
This sample satisfies the constraints of test point .
[Sample Explanation #5]
This sample satisfies the constraints of test point .
[Sample Explanation #6]
This sample satisfies the constraints of test point .
[Constraints]
Let , .
For all testdata, it is guaranteed that , , , , .
| Test Point ID | Special Property | ||
|---|---|---|---|
| None | |||
| A | |||
| B | |||
| C | |||
| None |
Special property A: .
Special property B: ,.
Special property C: ,,.
Translated by ChatGPT 5