#abc376e. E - Max × Sum
E - Max × Sum
Score : points
问题陈述
给定两个长度为 的序列: 和 。
设 是 的一个大小为 的子集。在这里,找到以下表达式的最小可能值:
$\displaystyle \left(\max_{i \in S} A_i\right) \times \left(\sum_{i \in S} B_i\right).$
你给出了 个测试用例;解决每一个。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given sequences of length : and .
Let be a subset of of size . Here, find the minimum possible value of the following expression:
$\displaystyle \left(\max_{i \in S} A_i\right) \times \left(\sum_{i \in S} B_i\right).$
You are given test cases; solve each of them.
Constraints
- The sum of over all test cases is at most .
- All input values are integers.
Input
The input is given from Standard Input in the following format. Here, denotes the -th test case.
Each test case is given in the following format:
Output
Print lines. The -th line should contain the answer for the -th test case.
Sample Input 1
3
3 2
3 7 6
9 2 4
5 3
6 4 1 5 9
8 6 5 1 7
10 6
61 95 61 57 69 49 46 47 14 43
39 79 48 92 90 76 30 16 30 94
Sample Output 1
42
60
14579
In the first test case, for , the value of the expression is , which is the minimum.