English · Original
Chinese · Translation
Formal · Original
_Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red colour, light, and cracking noise, all of which frighten the monster out of coming._
Little Tommy has _n_ lanterns and Big Banban has _m_ lanterns. Tommy's lanterns have brightness _a_1, _a_2, ..., _a__n_, and Banban's have brightness _b_1, _b_2, ..., _b__m_ respectively.
Tommy intends to hide one of his lanterns, then Banban picks one of Tommy's non-hidden lanterns and one of his own lanterns to form a pair. The pair's brightness will be the product of the brightness of two lanterns.
Tommy wants to make the product as small as possible, while Banban tries to make it as large as possible.
You are asked to find the brightness of the chosen pair if both of them choose optimally.
## Input
The first line contains two space-separated integers _n_ and _m_ (2 ≤ _n_, _m_ ≤ 50).
The second line contains _n_ space-separated integers _a_1, _a_2, ..., _a__n_.
The third line contains _m_ space-separated integers _b_1, _b_2, ..., _b__m_.
All the integers range from - 109 to 109.
## Output
Print a single integer — the brightness of the chosen pair.
[samples]
## Note
In the first example, Tommy will hide 20 and Banban will choose 18 from Tommy and 14 from himself.
In the second example, Tommy will hide 3 and Banban will choose 2 from Tommy and 1 from himself.
_Nian_ 是一种生活在深海中的怪物。每年它都会现身陆地,吞噬牲畜甚至人类。为了驱赶这只怪物,人们用红色、灯光和爆裂的声响充满村庄,所有这些都能吓跑怪物。
小汤米有 #cf_span[n] 个灯笼,大斑斑有 #cf_span[m] 个灯笼。汤米的灯笼亮度为 #cf_span[a1, a2, ..., an],斑斑的灯笼亮度为 #cf_span[b1, b2, ..., bm]。
汤米打算隐藏他其中一个灯笼,然后斑斑从汤米未隐藏的灯笼中选择一个,再从自己的灯笼中选择一个,组成一对。这对灯笼的亮度是两个灯笼亮度的乘积。
汤米希望使乘积尽可能小,而斑斑则希望使其尽可能大。
请你求出,当双方都采取最优策略时,最终选出的这对灯笼的亮度是多少。
第一行包含两个用空格分隔的整数 #cf_span[n] 和 #cf_span[m](#cf_span[2 ≤ n, m ≤ 50])。
第二行包含 #cf_span[n] 个用空格分隔的整数 #cf_span[a1, a2, ..., an]。
第三行包含 #cf_span[m] 个用空格分隔的整数 #cf_span[b1, b2, ..., bm]。
所有整数的范围为 #cf_span[ - 109] 到 #cf_span[109]。
请输出一个整数 —— 所选这对灯笼的亮度。
在第一个例子中,汤米会隐藏 #cf_span[20],斑斑会从汤米那里选择 #cf_span[18],从自己那里选择 #cf_span[14]。
在第二个例子中,汤米会隐藏 #cf_span[3],斑斑会从汤米那里选择 #cf_span[2],从自己那里选择 #cf_span[1]。
## Input
第一行包含两个用空格分隔的整数 #cf_span[n] 和 #cf_span[m](#cf_span[2 ≤ n, m ≤ 50])。第二行包含 #cf_span[n] 个用空格分隔的整数 #cf_span[a1, a2, ..., an]。第三行包含 #cf_span[m] 个用空格分隔的整数 #cf_span[b1, b2, ..., bm]。所有整数的范围为 #cf_span[ - 109] 到 #cf_span[109]。
## Output
请输出一个整数 —— 所选这对灯笼的亮度。
[samples]
## Note
在第一个例子中,汤米会隐藏 #cf_span[20],斑斑会从汤米那里选择 #cf_span[18],从自己那里选择 #cf_span[14]。在第二个例子中,汤米会隐藏 #cf_span[3],斑斑会从汤米那里选择 #cf_span[2],从自己那里选择 #cf_span[1]。
**Definitions**
Let $ n, m \in \mathbb{Z} $ with $ 2 \leq n, m \leq 50 $.
Let $ A = (a_1, a_2, \dots, a_n) \in \mathbb{Z}^n $ be Tommy’s lantern brightnesses.
Let $ B = (b_1, b_2, \dots, b_m) \in \mathbb{Z}^m $ be Banban’s lantern brightnesses.
**Constraints**
$ -10^9 \leq a_i, b_j \leq 10^9 $ for all $ i \in \{1,\dots,n\}, j \in \{1,\dots,m\} $.
**Objective**
Tommy chooses an index $ i^* \in \{1,\dots,n\} $ to hide (removing $ a_{i^*} $ from consideration).
Then Banban chooses $ i \in \{1,\dots,n\} \setminus \{i^*\} $ and $ j \in \{1,\dots,m\} $ to maximize $ a_i \cdot b_j $.
Tommy chooses $ i^* $ to minimize this maximum value.
Find:
$$
\min_{i^* \in \{1,\dots,n\}} \max_{\substack{i \in \{1,\dots,n\} \\ i \ne i^*}} \max_{j \in \{1,\dots,m\}} (a_i \cdot b_j)
$$
API Response (JSON)
{
"problem": {
"name": "A. A Compatible Pair",
"description": {
"content": "_Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red col",
"description_type": "Markdown"
},
"platform": "Codeforces",
"limit": {
"time_limit": 1000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "CF934A"
},
"statements": [
{
"statement_type": "Markdown",
"content": "_Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red col...",
"is_translate": false,
"language": "English"
},
{
"statement_type": "Markdown",
"content": "_Nian_ 是一种生活在深海中的怪物。每年它都会现身陆地,吞噬牲畜甚至人类。为了驱赶这只怪物,人们用红色、灯光和爆裂的声响充满村庄,所有这些都能吓跑怪物。\n\n小汤米有 #cf_span[n] 个灯笼,大斑斑有 #cf_span[m] 个灯笼。汤米的灯笼亮度为 #cf_span[a1, a2, ..., an],斑斑的灯笼亮度为 #cf_span[b1, b2, ..., bm]。\n\n汤米打算隐藏...",
"is_translate": true,
"language": "Chinese"
},
{
"statement_type": "Markdown",
"content": "**Definitions** \nLet $ n, m \\in \\mathbb{Z} $ with $ 2 \\leq n, m \\leq 50 $. \nLet $ A = (a_1, a_2, \\dots, a_n) \\in \\mathbb{Z}^n $ be Tommy’s lantern brightnesses. \nLet $ B = (b_1, b_2, \\dots, b_m) \\i...",
"is_translate": false,
"language": "Formal"
}
]
}