Sum of four values - MarisaOJ: Marisa Online Judge

Sum of four values

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $A$ consisting of $n$ elements and an integer $x$, determine whether there exist four distinct indices $i, j, k, p$ such that $A_i + A_j + A_k + A_p = x$. ### Input - The first line contains two integers $n$ and $x$. - The second line contains $n$ integers $A_i$. ### Output - Print `YES` if such indices exist, otherwise print `NO`. ### Constraints - $1 \leq n \leq 1000$. - $1 \leq A_i, x \leq 10^9$. ### Example Input: ``` 8 15 3 2 5 8 1 3 2 3 ``` Output: ``` YES ```