#T585. 寻找两数和

寻找两数和

Description

Given a non-decreasing integer sequence a1,a2,,an1,ana_1, a_2, \dots, a_{n-1}, a_n and an integer xx, determine whether there exist two numbers in the sequence whose sum equals xx. If such a pair exists, output <span>”YES”</span>; otherwise, output <span>”NO”</span>.

Input Format

There are multiple test cases. For each test case:

  • The first line contains two integers, nn and xx (where nn and xx are both less than 100,000), representing the number of elements in the integer sequence and the target sum xx, respectively.
  • The second line contains nn integers, a1a_1 to ana_n, separated by spaces. The sequence satisfies $1 \leq a_1 \leq a_2 \leq \dots \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 <span>YES</span> or <span>NO</span>.

5 10
1 2 3 4 5
6 12
1 3 5 7 9 11
0 0

NO
YES

## Source

CodesOnline