The Romanian word "popeală" has its origins in a Romanian historical novella, "Alexandru Lăpușneanul", where the eponymous Prince of Moldavia uses a variation of the term to describe his upcoming revenge on his usurpers. The term was recently revived, somewhat surprisingly, in the Romanian programming contest scene. It's used to describe any situation in which the scientific committee makes life harder for the contestants in an unorthodox and (usually) involuntary way: very strict time limits, invalid test cases, wrong statements, stealing keyboards and other such mechanisms. This task is about such a "popeală".
Consider a programming contest with
How subtasks work: Each test case will belong to exactly one subtask. A subtask can contain any
number of test cases, but it cannot be empty. If a contestant fails any test case of a certain subtask, his or
her score for that subtask will be
This is a common practice in programming contests, but the catch is that the scientific committee wants to do this after the contest is over. They know what test cases were solved correctly for each contestant and they want to group the tests into subtasks such as to minimize the total number of points scored in the contest.
Specifically, you are given an integer array Points[]
of size Points[i]
will contain the point
value of the Results[][]
of size Results[i][j]
will be equal to
Otherwise, it will be equal to
You should help the committee. They want to know, for each value
Input
The input will contain three space-separated positive integers on its first line: Points[]
array. The following Results[][]
matrix.
Output
The output should contain
Notes and Constraints
Points[i]
, for all . It is also guaranteed thatPoints[1]
Points[2]
Points[T]
for all test cases.- For test cases worth
points, . - For test cases worth another
points, . - For test cases worth another
points, .
Sample Input
2 3 3
4 3 5
101
110
Sample Output
0
8
16
Explanation for Sample Output
There are Points[]
array is
In the case of a single subtask, the total number of points that can be achieved is equal
to
There are two ways to group the test cases in two subtasks. One of them produces a total
number of
There is also a single way to group the test cases into three subtasks, which produces a
total number of
Comments