#4809. Invisible Hand

0

Invisible Hand

Invisible Hand

题目描述

There are NN sellers and MM buyers in an apple market. The ii-th seller may sell an apple for AiA_i yen or more (yen is the currency in Japan). The ii-th buyer may buy an apple for BiB_i yen or less. Find the minimum integer XX that satisfies the following condition. Condition: The number of people who may sell an apple for XX yen is greater than or equal to the number of people who may buy an apple for XX yen.

输入格式

The input is given from Standard Input in the following format: NN MM A1A_1 …\ldots ANA_N B1B_1 …\ldots BMB_M

输出格式

Print the answer.

3 4
110 90 120
100 80 120 10000
110
5 2
100000 100000 100000 100000 100000
100 200
201
3 2
100 100 100
80 120
100

提示

1≤N,M≤2×1051 \leq N,M \leq 2\times 10^5 1≤Ai,Bi≤1091\leq A_i,B_i \leq 10^9 All input values are integers.Two sellers, the 11-st and 22-nd, may sell an apple for 110110 yen; two buyers, the 33-rd and 44-th, may buy an apple for 110110 yen. Thus, 110110 satisfies the condition. Since an integer less than 110110 does not satisfy the condition, this is the answer.

标签: AtCoder|abc312C

来源

AtCoder|abc312C