#P10303. [THUWC 2020] 报告顺序
[THUWC 2020] 报告顺序
Problem Description
Today, Yazid is going to listen to people giving reports. For convenience, we number these people from to .
Yazid has an excitement level, initially , and this value will change as the reports go on.
The report of person () can be described by three numbers . This means that if, before listening to their report, Yazid’s excitement level is , then after listening to it, Yazid’s excitement level will become .
Yazid also needs to take final exams, so he wants to be as excited as possible after listening to all the reports. Therefore, your task is to help Yazid decide the order of all reports so that Yazid’s excitement level is maximized after everyone has finished presenting.
Input Format
The first line contains two integers separated by spaces.
The next lines describe the people’s reports. Line of this part contains three integers separated by spaces.
Output Format
Output one integer in one line, representing the maximum excitement level Yazid can have after listening to all the reports.
2 3
0 1 1
0 2 0
8
1 -2
8 -4 1
25
Hint
[Sample Explanation #1]
If Yazid listens to the first person’s report first, and then the second person’s report, the final excitement level is .
If Yazid listens to the second person’s report first, and then the first person’s report, the final excitement level is .
So the maximum excitement level is .
[Sample Explanation #2]
There is only one report. Yazid’s initial excitement level is , so after listening to the report, the excitement level is .
[Subtasks]
Subtask 1 (13 points): .
Subtask 2 (19 points): .
Subtask 3 (23 points): .
Subtask 4 (45 points): no special constraints.
For all testdata, it is guaranteed that , and the absolute values of are all at most .
[Hint]
Under the constraints, the answer will not exceed the range of a 128-bit signed integer, so you may try using __int128 to help implement your algorithm.
Translated by ChatGPT 5