Twins in the Vault
Medium1s time · 256MB memory · arrays, hash map
The vault at Grelka Station opens only when two different crates are plugged into the console and their charges add up exactly to the activation value.
Determine whether any two elements at different positions sum to the given target.
Input
The first line contains two integers n and t — the number of crates and the activation value.
The second line contains n integers v₁ … vₙ — the charges.
Output
Print YES if two different positions i ≠ j satisfy vᵢ + vⱼ = t, otherwise NO.
Constraints
- 1 ≤ n ≤ 2·10⁴
- −10⁷ ≤ vᵢ ≤ 10⁷
- −2·10⁷ ≤ t ≤ 2·10⁷
Samples
Input 1
5 9 2 7 11 15 4
Output 1
YES
Input 2
4 100 1 2 3 4
Output 2
NO
Sign in (top right) to run or submit.