#T401. 寻找两数和
寻找两数和
Description
There is a non-decreasing integer sequence (a_1, a_2, \ldots, a_{n-1}, a_n). Given an integer (x), determine whether there exist two numbers in the sequence whose sum is (x). If such a pair exists, output <span>”YES”</span>; otherwise, output <span>”NO”</span>.
Input Format
The input consists of multiple test cases. For each test case, the first line contains two integers (n) and (x) (where (n) and (x) are both less than 100,000), representing the number of elements in the integer sequence and the target sum (x), respectively. The second line contains (n) integers, (a_1) to (a_n), separated by spaces. The sequence satisfies (1 \leq a_1 \leq a_2 \leq \ldots \leq a_{n-1} \leq a_n < 2^{31}). The input ends with 0.
Output Format
For each test case, output a single line containing either YES or NO.
5 10
1 2 3 4 5
6 12
1 3 5 7 9 11
0 0
NO
YES
Translation
CodesOnline
(Note: Since "CodesOnline" appears to be a proper noun or brand name, it is kept as-is in the translation without modification to maintain accuracy.)