102091: [AtCoder]ABC209 B - Can you buy them all?

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

Description

Score : $200$ points

Problem Statement

Takahashi's shop sells $N$ products. The usual price of the $i$-th product is $A_i$ yen (Japanese currency).
It has a bargain sale today, with a discount of $1$ yen off the usual prices for the $2$-nd, $4$-th, and the subsequent even-indexed products. The $1$-st, $3$-rd, and the subsequent odd-indexed products are sold for their usual prices.
You have $X$ yen. Can you buy all the $N$ products with this money?

Constraints

  • $1 \leq N \leq 100$
  • $1 \leq X \leq 10000$
  • $1 \leq A_i \leq 100$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $X$
$A_1$ $A_2$ $\ldots$ $A_N$

Output

If you can buy all the $N$ products, print Yes; otherwise, print No.


Sample Input 1

2 3
1 3

Sample Output 1

Yes

You can buy the $1$-st product for $1$ yen and the $2$-nd product for $2$ yen, $1$ yen off the usual price. You have just enough money, $3$ yen, to buy both of them.


Sample Input 2

4 10
3 3 4 4

Sample Output 2

No

You can buy these four products for $3$ yen, $2$ yen, $4$ yen, and $3$ yen, respectively. You need $12$ yen to buy all of them, and since you have only $10$ yen, you cannot buy all of them.


Sample Input 3

8 30
3 1 4 1 5 9 2 6

Sample Output 3

Yes

Input

题意翻译

你今天买了 $n$ 件商品,第 $i$ 件商品的标价为 $a_i$ 元。今天超市搞优惠,编号( $i$ )是 $2$ 的倍数的商品在售出时全部降价 $1$ 元。你今天在结账时发现自己带了 $x$ 元。你决定编写程序,依次输入 $n,x$ 以及所有的 $a_i$ ,程序可以帮你判断你今天带的钱够不够并输出判断结果。

Output

分数:200分

问题描述

高桥的商店有$N$种商品。第$i$种商品的原价是$A_i$日元(日本货币)。

今天商店有促销活动,第2个、第4个以及后续的偶数编号的商品每件降价1日元。第1个、第3个以及后续的奇数编号的商品按原价销售。

你有$X$日元。你能否用这笔钱买下所有$N$种商品呢?

限制条件

  • $1 \leq N \leq 100$
  • $1 \leq X \leq 10000$
  • $1 \leq A_i \leq 100$
  • 所有输入值都是整数。

输入

从标准输入以以下格式获取输入:

$N$ $X$
$A_1$ $A_2$ $\ldots$ $A_N$

输出

如果可以买下所有$N$种商品,打印Yes;否则,打印No


样例输入1

2 3
1 3

样例输出1

Yes

你可以用1日元购买第1个商品,2日元购买第2个商品,比原价便宜1日元。你正好有3日元,可以买下这两件商品。


样例输入2

4 10
3 3 4 4

样例输出2

No

这四种商品分别可以以3日元、2日元、4日元和3日元的价格购买。要买下所有商品需要12日元,但你只有10日元,所以无法买下所有商品。


样例输入3

8 30
3 1 4 1 5 9 2 6

样例输出3

Yes

加入题单

上一题 下一题 算法标签: