题目描述
Problem Background
Yume has recently been playing a music game called "LoveLive! School idol festival." He loves this game because it is very friendly to players who are not lucky, as even if you can't draw good cards, you can still earn rewards by achieving certain goals in the twice-monthly events.
Problem Description
Yume is very fond of the card art for the current event rewards, so he has decided to grind this event to get the rewards. The rules for this event are special: players need to complete all designated songs (each song can only be played once) before the event's end time and achieve a certain score to receive the rewards. If all songs are not completed or the score is below the reward threshold before the deadline, the rewards cannot be claimed. Each song has a limited reward window; if the song is completed within this time frame, a certain score is earned (earned score = open time - total time used so far). If the song is completed after this time frame, no score is awarded.
This rule should be easy for seasoned players like Yume, but unfortunately, he mistook the event's end time for its start time. When he excitedly logged in, he was shocked to find that the event was almost over. Now, he wants to know if he can complete all the songs and achieve the reward threshold within the remaining time to get the event card. To save time, he has asked you to solve this problem. Please calculate for him whether he can achieve the goal within the remaining time. If possible, tell him the sequence in which to complete each song.
Input Format
The first line of input contains three integers $n, m, t$, representing the number of songs to be completed, the minimum score required to receive rewards, and the remaining time until the event ends, respectively.
The next $n$ lines each contain a string $S_i$ and two integers $T_i$ and $M_i$, representing the song name $S_i$, the time required to complete the $i$-th song $T_i$, and the remaining reward open time for the $i$-th song $M_i$. It is guaranteed that $T_i \le M_i$. The data is provided in lexicographical order of $S_i$.
Output Format
If Yume can complete the specified goals and receive the rewards before the event ends, output an integer $C$ on the first line, indicating the maximum score that can be obtained under the premise of receiving rewards.
The next $n$ lines should output the song names in the order they are completed. If there are multiple possibilities, output the one with the smallest lexicographical order.
If Yume cannot complete all the songs before the event ends, output No Answer.
Sample Input and Output
Sample Input #1
3 2 10
BokutachiwaHitotsunoHikari 3 8
Korekara 1 2
SnowHalation 2 5
Sample Output #1
6
SnowHalation
BokutachiwaHitotsunoHikari
Korekara
Sample Input #2
2 1 2
AoizoraJumpingHeart 1 2
TimeLapse 2 4
Sample Output #2
No Answer
Notes
For $0\%$ of the data, it is identical to the test data.
For $20\%$ of the data, $n \le 5$.
For $40\%$ of the data, $n \le 9$.
For $70\%$ of the data, $n \le 15$.
Another $10\%$ of the data satisfies $\sum\limits^{n}_{i=1} T_i < t$.
For $100\%$ of the data, $n \le 22$, and the length of $S_i$ does not exceed $50$. It is guaranteed that $m, t, M_i, T_i$ and their sums are within the maximum range of int.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分