#arc176e. E - Max Vector
E - Max Vector
Score: points
问题陈述
给定两个长度为的正整数序列: 和 。
此外,还给出了个长度为的正整数序列。第个序列是 。
对于每个,你必须执行以下操作之一。你可以独立选择为每个执行哪个操作。
- 将所有满足的整数的替换为 。
- 将所有满足的整数的替换为 。
在所有操作完成后,找出 的可能最小值。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given two length- sequences of positive integers: and .
Additionally, you are given length- sequences of positive integers. The -th sequence is .
For each , you must perform one of the following operations. You can independently choose which operation to perform for each .
- Replace with for all integers such that .
- Replace with for all integers such that .
Find the minimum possible value of after all operations.
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
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 with , making .
- Replace with , making .
This sequence of operations achieves .
Sample Input 2
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
Sample Input 3
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