Score: 800 points
问题陈述
给定两个长度为N的正整数序列:X=(X1,X2,…,XN) 和 Y=(Y1,Y2,…,YN)。
此外,还给出了M个长度为N的正整数序列。第i个序列是 Ai=(Ai,1,Ai,2,…,Ai,N)。
对于每个i=1,2,…,M,你必须执行以下操作之一。你可以独立选择为每个i执行哪个操作。
- 将所有满足1≤j≤N的整数j的Xj替换为 max(Xj,Ai,j)。
- 将所有满足1≤j≤N的整数j的Yj替换为 max(Yj,Ai,j)。
在所有操作完成后,找出 ∑j=1N(Xj+Yj) 的可能最小值。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given two length-N sequences of positive integers: X=(X1,X2,…,XN) and Y=(Y1,Y2,…,YN).
Additionally, you are given M length-N sequences of positive integers. The i-th sequence is Ai=(Ai,1,Ai,2,…,Ai,N).
For each i=1,2,…,M, you must perform one of the following operations. You can independently choose which operation to perform for each i.
- Replace Xj with max(Xj,Ai,j) for all integers j such that 1≤j≤N.
- Replace Yj with max(Yj,Ai,j) for all integers j such that 1≤j≤N.
Find the minimum possible value of ∑j=1N(Xj+Yj) after all operations.
Constraints
- 1≤N≤10
- 1≤M≤500
- 1≤Xj,Yj,Ai,j≤500
The input is given from Standard Input in the following format:
N M
X1 X2 … XN
Y1 Y2 … YN
A1,1 A1,2 … A1,N
A2,1 A2,2 … A2,N
⋮
AM,1 AM,2 … AM,N
Output
Print the answer.
3 2
4 4 2
3 1 5
2 5 2
1 2 4
Sample Output 1
21
One optimal sequence of operations is as follows:
- Replace Xj with max(Xj,A1,j), making X=(4,5,2).
- Replace Yj with max(Yj,A2,j), making Y=(3,2,5).
This sequence of operations achieves ∑j=1N(Xj+Yj)=21.
3 5
4 13 10
14 9 4
4 6 4
13 18 16
8 13 5
7 18 17
20 20 14
Sample Output 2
84
5 12
330 68 248 387 491
295 366 376 262 192
280 121 17 168 455
288 179 210 378 490
150 275 165 264 287
66 331 207 282 367
303 215 456 214 18
227 326 103 443 427
395 57 107 350 227
318 231 146 2 116
57 325 124 383 260
147 319 23 177 445
254 198 32 85 56
68 177 356 41 471
Sample Output 3
3595