2299: Number-picking game

内存限制:32 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

It was a windy night and raining heavily. A boy named Clever Mole was in his house with his girlfriend. Both of them were pretty hungry, however, neither of them were willing to buy something outside their haven. As finger-guessing game was out of style at that time, so Clever Mole put forward an idea -- number-picking game. The game is quite simple as there are 2n numbers in one straight line and each of them is from 1 to 9. Now the rule is that if Clever Mole takes the first move, he can only take one number from one side of the line(if the line is 9 8 3 2 4 6, he can only take 9 or 6 at one time). Then it was his girlfriend's turn, she can also take one number from only one side of the line(if the line is 9 8 3 2 4,she can only take 9 or 4,or if the line is 8 3 2 4 6,she can only take 8 or 6)......So at last ,each of them has n numbers in hand. Finally, add the n numbers up , Clever Mole gets sum1 and his girlfriend gets sum2. If sum1>=sum2, Clever Mole wins,and his girlfriend has to buy something delicious. Suppose that if Clever Mole only want to stay at home and drinks red tea as pre-dinner drink, but he doesn’t know whether he can win or not . So can you tell him the result in an efficient way?

输入格式

The input contains several test cases, terminated by EOF.For each test case, the first line contains 2 integers n,m, denoting there are 2n numbers in the second line and if m=1, Clever Mole takes the first move ;if m=2 his girlfriend takes the first move.(0< n <=1000,1<= m <=2)

输出格式

In each test cases,output "Yes" if Clever Mole can have his wish fulfilled,and output "No" if he can't.

输入样例 复制

5 1
8 2 3 4 1 6 5 9 4 1
7 2
1 3 5 7 9 2 4 6 8 6 4 2 5 9

输出样例 复制

Yes
No

数据范围与提示

Be efficient! --Clever Mole