#P8983. 「DROI」Round 1 失控
「DROI」Round 1 失控
Background
Being out of control might actually be being rational.
Problem Description
You are given an matrix and two permutations of length .
We say an element is out of control if and only if and , where is a given constant. In particular, we define that no element in row and row is out of control no matter what.
Then you are also given two sequences and , both of length .
You have types of operations. The -th operation adds to all elements in a chosen row, and costs . Each operation type can be used any number of times, but for each row, you may either apply exactly one of these operation types or do nothing. Also, you must ensure that among any two adjacent rows, at most one row is operated on.
Find the minimum total cost to make every element in matrix not out of control (the testdata guarantees that a solution exists).
Input Format
The first line contains four integers .
The next lines are as follows: the first lines each contain numbers, describing matrix . Lines and each contain numbers, describing permutations and , respectively. The last two lines each contain numbers, describing sequences and , respectively.
Output Format
Output one integer in a single line, representing the answer.
3 3 5 10
1 2 6
7 3 11
9 44 5
2 3 1
1 3 2
5 10 15 20 25
6 6 6 6 6
0
8 8 8 28
49 11 44 31 25 37 41 1
29 38 46 21 21 17 45 47
1 37 11 31 8 15 15 47
21 47 15 6 11 9 40 28
21 29 1 11 39 15 21 35
26 20 3 38 1 41 27 21
41 41 31 16 11 1 24 3
33 15 23 26 7 47 49 8
3 8 2 4 6 5 1 7
7 5 8 3 6 1 4 2
36 13 12 3 38 49 22 55
20 24 2 30 26 25 17 25
32
Hint
Sample Explanation #1
Obviously, for sample 1, performing no operation is enough to ensure that all elements are not out of control.
Sample Explanation #2
Apply operation on row , and apply operation on row . It can be proven that there is no better solution.
Constraints
"This problem uses bundled subtasks."
-
: .
-
: .
-
: .
-
: no special restrictions.
For of the testdata: , , , .
The input size is large. Please use a fast input method.
Hint
- This problem is not strict about constant factors. If you feel your algorithm is just a bit too slow to pass the next Subtask, please do not get stuck optimizing meaningless constants, because that missing part may need a better algorithm to make up for it.
Translated by ChatGPT 5