#P8732. [蓝桥杯 2020 国 ABC] 答疑
[蓝桥杯 2020 国 ABC] 答疑
Problem Description
There are students who come to the teacher for Q&A at the same time. Each student has estimated in advance the time needed for their own Q&A. The teacher can decide the order of Q&A, and students enter the teacher’s office one by one for Q&A.
The Q&A process for one student is as follows:
-
First, the student enters the office. Student needs milliseconds.
-
Then the student asks questions and the teacher answers. Student needs milliseconds.
-
After the Q&A is finished, the student is very happy and sends a message in the course chat group. The time needed for this can be ignored.
-
Finally, the student packs up and leaves the office, which takes milliseconds. Usually it takes seconds, seconds, or seconds, i.e. can be , , or .
After one student leaves the office, the next student can immediately enter.
The Q&A starts at time . The teacher wants to arrange the Q&A order reasonably so that the sum of the times when students send messages in the course chat group is minimized.
Input Format
The first line contains an integer , representing the number of students.
The next lines describe the time for each student. The -th line contains three integers , with the meanings described above.
Output Format
Output one integer, representing the minimum possible sum of the times when students send messages in the course chat group.
3
10000 10000 10000
20000 50000 20000
30000 20000 30000
280000
Hint
Sample Explanation
If the Q&A order is , then the message sending times are .
Constraints and Notes
For of the testdata, .
For of the testdata, .
For all testdata, , , , , i.e. must be one of , , or .
Lanqiao Cup 2020 National Finals, Group A Problem H (Group B Problem H, Group C Problem J).
Translated by ChatGPT 5