304675: CF892A. Greed
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Greed
题意翻译
## 题目描述 Jafar有$n$ 个装可乐的罐子。每一个罐子都被用两个整数描述:剩下的可乐的体积$a_i$ 和罐子的容积$b_i$ ($a_i\leq b_i$ ) Jafar已经决定把剩下的所有可乐倒进$2$ 个罐子,帮他看看是否可以! ### 输入格式: 第一行输入包含一个整数$n$ ($2\leq n\100000$ )— 可乐罐的数量。 第二行包含$n$ 个空格分隔的整数$a_1,a_2,\dots,a_n$ ($0\leq a_i \leq 10^9$ )— 罐子里剩余可乐的体积。 第二行包含$n$ 个空格分隔的整数$b_1,b_2,\dots,b_n$ ($0\leq b_i \leq 10^9$ )— 罐子的容积。 ### 输出格式: 如果可能将所有剩余的可乐倒进两个罐子输出"YES"(不含引号)。否则输出"NO"(不含引号)。 By @Khassar题目描述
Jafar has $ n $ cans of cola. Each can is described by two integers: remaining volume of cola $ a_{i} $ and can's capacity $ b_{i} $ ( $ a_{i} $ $ <= $ $ b_{i} $ ). Jafar has decided to pour all remaining cola into just $ 2 $ cans, determine if he can do this or not!输入输出格式
输入格式
The first line of the input contains one integer $ n $ ( $ 2<=n<=100000 $ ) — number of cola cans. The second line contains $ n $ space-separated integers $ a_{1},a_{2},...,a_{n} $ ( $ 0<=a_{i}<=10^{9} $ ) — volume of remaining cola in cans. The third line contains $ n $ space-separated integers that $ b_{1},b_{2},...,b_{n} $ ( $ a_{i}<=b_{i}<=10^{9} $ ) — capacities of the cans.
输出格式
Print "YES" (without quotes) if it is possible to pour all remaining cola in $ 2 $ cans. Otherwise print "NO" (without quotes). You can print each letter in any case (upper or lower).
输入输出样例
输入样例 #1
2
3 5
3 6
输出样例 #1
YES
输入样例 #2
3
6 8 9
6 10 12
输出样例 #2
NO
输入样例 #3
5
0 0 5 0 0
1 1 8 10 5
输出样例 #3
YES
输入样例 #4
4
4 1 0 3
5 2 2 3
输出样例 #4
YES