#P5449. [THUPC 2018] 《算法与数据结构》小助教招募通知
[THUPC 2018] 《算法与数据结构》小助教招募通知
Description
The content of the course "Algorithms and Data Structures" is divided into knowledge points, and each knowledge point has corresponding practice problems. Each problem has two attribute values: the -th practice problem of the -th knowledge point can increase the algorithm ability of the student who solves it by , and increase the data structure ability by . These attribute values are all integers, but they may be negative, and there may even be practice problems where both attributes are negative. (Do not ask how such problems got into the problem set...)
There are students registered for next year's "Algorithms and Data Structures" course. By examining each student's previous learning situation, Little O decides to teach each student according to their aptitude. Specifically, for the -th student and the -th knowledge point, Little O wants this student to complete exactly practice problems of this knowledge point.
In fact, Little O has close ties with University T and wants to stir up some trouble at University U. For each student, let the total improvements in algorithm ability and data structure ability from all selected practice problems be and , respectively. Little O's goal is to maximize . In this way, no matter how much the student's abilities increase or decrease in either aspect, it is what Little O wants.
Please compute the maximum value of this objective for each student.
Input Format
Each input file contains only one testdata.
-
The first line contains three positive integers .
-
The next lines each contain integers; in the -th of these lines, the -th integer is .
-
The next lines each contain integers; in the -th of these lines, the -th integer is .
-
The next lines each contain integers; in the -th of these lines, the -th integer is .
For each line of input, if multiple numbers are given, then adjacent numbers are separated by exactly one space.
Output Format
Output lines, each with 1 integer: the integer on line is the maximum value of for the -th student.
2 4 4
1 1 -1 -1
0 10 0 -1
1 -1 1 -1
10 0 -1 0
1 1
2 1
1 2
2 2
122
144
242
244
Hint
Sample Explanation
There are 2 knowledge points, and each knowledge point has 4 practice problems; there are 4 students.
Take the 2nd student as an example. We need to select exactly 2 practice problems from the 1st knowledge point and exactly 1 practice problem from the 2nd knowledge point for this student. One optimal plan is to choose the 1st and 3rd problems in the 1st knowledge point, and choose the 1st problem in the 2nd knowledge point. The improvement in algorithm ability from these problems is , and the improvement in data structure ability is . Then , and there is no better plan.
Constraints
, , , and all and are in the range . For the final testdata, all are generated independently and uniformly at random in the range .
Hint
Each output number may be very large, and may even exceed the range of 64-bit integers.
-
In C++, you can use the
__int128_ttype to represent signed 128-bit integers, or use__uint128_tto represent unsigned 128-bit integers. These two data types cannot be directly used for input/output. -
In Java, you can use the
BigIntegerclass.
Copyright Information
From the 2018 Tsinghua University Programming Contest and Intercollegiate Invitational (THUPC2018). Thanks to Pony.ai for supporting this contest.
Resources such as editorials can be found at https://github.com/wangyurzee7/THUPC2018.
Translated by ChatGPT 5
京公网安备 11011102002149号