301850: CF350A. TL

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

TL

题意翻译

## 题目描述 珂朵莉想准备一场洛谷月赛。她想给自己出的唯一一道题设置一个时限。 珂朵莉写了`n`个程序,并且知道了它们的运行所需时间。珂朵莉还写了`m`会$TLE$的程序,也知道它们的运行时间。 假设珂朵莉在问题中设置时限为`v`秒。 一个程序的运行时间不超过`v`秒,它就可以$AC$。 如果一个解的运行时间不超过$\frac{v}{2}$秒,则它就可以$AC$并且得到一些奖励时间。 因此,珂朵莉决定设置`v`秒的时限,满足以下条件: - `v`为正整数 - 所有正解都可以$AC$ - 至少有一个正解可以获得奖励时间 - 所有会$TLE$的程序都不会$AC$ - `v`是满足上述条件中的最小值 请帮助珂朵莉求出`v`的最小值或者告诉她这个最小值不存在。 ## 输入输出格式: 输入: - 第一行包含两个整数`n`,`m` - 第二行包含`n`个整数,表示正解代码运行时间 - 第三行包含`m`个整数,表示非正解代码运行时间 输出: - 第一行包含一个整数,表示最小的`v`值,如果不存在,输出`-1`即可 ## 数据范围: (100$\leq$`m`$\leq$1001$\leq$`n`)

题目描述

Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it. Valera has written $ n $ correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote $ m $ wrong solutions and for each wrong solution he knows its running time (in seconds). Let's suppose that Valera will set $ v $ seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most $ v $ seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, $ a $ seconds, an inequality $ 2a<=v $ holds. As a result, Valera decided to set $ v $ seconds TL, that the following conditions are met: 1. $ v $ is a positive integer; 2. all correct solutions pass the system testing; 3. at least one correct solution passes the system testing with some "extra" time; 4. all wrong solutions do not pass the system testing; 5. value $ v $ is minimum among all TLs, for which points $ 1 $ , $ 2 $ , $ 3 $ , $ 4 $ hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist.

输入输出格式

输入格式


The first line contains two integers $ n $ , $ m $ ( $ 1<=n,m<=100 $ ). The second line contains $ n $ space-separated positive integers $ a_{1},a_{2},...,a_{n} $ ( $ 1<=a_{i}<=100 $ ) — the running time of each of the $ n $ correct solutions in seconds. The third line contains $ m $ space-separated positive integers $ b_{1},b_{2},...,b_{m} $ ( $ 1<=b_{i}<=100 $ ) — the running time of each of $ m $ wrong solutions in seconds.

输出格式


If there is a valid TL value, print it. Otherwise, print -1.

输入输出样例

输入样例 #1

3 6
4 5 2
8 9 6 10 7 11

输出样例 #1

5

输入样例 #2

3 1
3 4 5
6

输出样例 #2

-1

Input

题意翻译

## 题目描述 珂朵莉想准备一场洛谷月赛。她想给自己出的唯一一道题设置一个时限。 珂朵莉写了`n`个程序,并且知道了它们的运行所需时间。珂朵莉还写了`m`会$TLE$的程序,也知道它们的运行时间。 假设珂朵莉在问题中设置时限为`v`秒。 一个程序的运行时间不超过`v`秒,它就可以$AC$。 如果一个解的运行时间不超过$\frac{v}{2}$秒,则它就可以$AC$并且得到一些奖励时间。 因此,珂朵莉决定设置`v`秒的时限,满足以下条件: - `v`为正整数 - 所有正解都可以$AC$ - 至少有一个正解可以获得奖励时间 - 所有会$TLE$的程序都不会$AC$ - `v`是满足上述条件中的最小值 请帮助珂朵莉求出`v`的最小值或者告诉她这个最小值不存在。 ## 输入输出格式: 输入: - 第一行包含两个整数`n`,`m` - 第二行包含`n`个整数,表示正解代码运行时间 - 第三行包含`m`个整数,表示非正解代码运行时间 输出: - 第一行包含一个整数,表示最小的`v`值,如果不存在,输出`-1`即可 ## 数据范围: (100$\leq$`m`$\leq$1001$\leq$`n`)

加入题单

算法标签: