#icpc2015summerday4i. [icpc2015summer_day4_i]Live Programming
[icpc2015summer_day4_i]Live Programming
MathJax.Hub.Config({ tex2jax: { inlineMath: [[""], ["\\(","\\)"]], processEscapes: true }}); blockquote { font-family: Menlo, Monaco, "Courier New", monospace; color: #333333; display: block; padding: 8.5px; margin: 0 0 9px; font-size: 12px; line-height: 18px; background-color: #f5f5f5; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; white-space: pre; white-space: pre-wrap; word-break: break-all; word-wrap: break-word; }
Problem Statement
A famous Japanese idol group, JAG48, is planning the program for its next live performance. They have different songs, , , ..., and . Each song has three integer parameters, , , and : denotes the length of , denotes the basic satisfaction points the audience will get when is performed, and denotes the feature value of that affects the audience's satisfaction. During the live performance, JAG48 can perform any number (but at least one) of the songs, unless the total length of the chosen songs exceeds the length of the live performance . They can decide the order of the songs to perform, but they cannot perform the same song twice or more.
The goal of this live performance is to maximize the total satisfaction points that the audience will get. In addition to the basic satisfaction points of each song, the difference between the feature values of the two songs that are performed consecutively affects the total satisfaction points. If there is no difference, the audience will feel comfortable. However, the larger the difference will be, the more frustrated the audience will be.
Thus, the total satisfaction points will be calculated as follows:
- If is the first song of the live performance, the total satisfaction points just after is equal to .
- If is the second or subsequent song of the live performance and is performed just after , is added to the total satisfaction points, because the audience will get frustrated if and are different.
Help JAG48 find a program with the maximum total satisfaction points.
Input
The input is formatted as follows.
The first line contains two integers and : the number of the available songs (), and the length of the live performance ().
The following lines represent the parameters of the songs. The -th line of them contains three integers, which are the parameters of : the length (), the basic satisfaction points (), and the feature value ().
You can assume that there is at least one song whose length is less than or equal to .
Output
Output the maximum total satisfaction points that the audience can get during the live performance.
Sample Input 1
2 10
10 200 1
10 100 100```
### Output for the Sample Input 1
```plain
200```
* * *
### Sample Input 2
```plain
3 15
5 100 1
5 100 2
5 100 4```
### Output for the Sample Input 2
```plain
295```
* * *
### Sample Input 3
```plain
3 10
5 200 200
5 200 201
5 300 1```
### Output for the Sample Input 3
```plain
399```
* * *
### Sample Input 4
```plain
3 20
5 100 200
5 100 201
5 300 1```
### Output for the Sample Input 4
```plain
300```
* * *
### Sample Input 5
```plain
5 61
14 49 7
31 46 4
30 55 5
52 99 1
34 70 3```
### Output for the Sample Input 5
```plain
103```
* * *