/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
長さ N の整数列 A=(A_1,A_2,\ldots,A_N) と整数 M が与えられます。
A の N 個の要素から 1 個を取り除くことで、残りの N-1 個の要素の和をちょうど M にできるか判定してください。
制約
- 2\le N\le 100
- 0\le M\le 10000
- 0\le A_i\le 100
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N M A_1 A_2 \ldots A_N
出力
A の N 個の要素から 1 個を取り除くことで、残りの N-1 個の要素の和をちょうど M にできる場合は Yes を、そうでない場合は No を出力せよ。
入力例 1
4 10 3 2 3 4
出力例 1
Yes
A_1,A_3,A_4 を選ぶと総和は 3+3+4=10 となります。したがって、 Yes を出力してください。
入力例 2
5 16 3 3 4 2 5
出力例 2
No
どのように 4 つの要素を選んでもその総和を 16 にすることはできません。したがって、 No を出力してください。
入力例 3
6 16 0 8 0 2 6 8
出力例 3
Yes
Score : 200 points
Problem Statement
You are given an integer sequence of length N, A=(A_1,A_2,\ldots,A_N), and an integer M.
Determine whether it is possible to remove one of the N elements of A so that the sum of the remaining (N-1) elements is exactly M.
Constraints
- 2\le N\le 100
- 0\le M\le 10000
- 0\le A_i\le 100
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N M A_1 A_2 \ldots A_N
Output
If it is possible to remove one of the N elements of A so that the sum of the remaining (N-1) elements is exactly M, print Yes; otherwise, print No.
Sample Input 1
4 10 3 2 3 4
Sample Output 1
Yes
If you choose A_1,A_3,A_4, the sum is 3+3+4=10. Therefore, print Yes.
Sample Input 2
5 16 3 3 4 2 5
Sample Output 2
No
No matter how you choose four elements, their sum is not equal to 16. Therefore, print No.
Sample Input 3
6 16 0 8 0 2 6 8
Sample Output 3
Yes