Array Has a Pair Summing to K

HARD · C · 3000ms

A rumor says two projects' combined marks equal exactly the passing threshold K — Tanvir must check if any such pair exists among all submitted marks. Read N integers and integer K. Print "YES" if any two DIFFERENT positions i≠j have a[i]+a[j]=K, else "NO". Aim for O(N) or O(N log N), not O(N^2), since N can be up to 10^5.

Input

First line N K, second line N integers.

Output

"YES" or "NO".

Constraints

1 ≤ N ≤ 10^5, |a_i|,|K| ≤ 10^9

Sample Input

5 9
2 7 4 1 5

Sample Output

YES
main.c
Loading editor…

Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.

Array Has a Pair Summing to K · DIU ContestHub