#K93657. Quadruplet Sum
Quadruplet Sum
Quadruplet Sum
You are given an array of integers \(A\) of length \(n\) and an integer target \(T\). Your task is to determine whether there exists a quadruplet \((A_i, A_j, A_k, A_l)\) with \(i < j < k < l\) such that:
\(A_i + A_j + A_k + A_l = T\)
If such a quadruplet exists, print Yes
; otherwise, print No
.
inputFormat
The first line of input contains two integers \(n\) and \(T\), where \(n\) is the number of elements in the array and \(T\) is the target sum.
The second line contains \(n\) space-separated integers representing the array \(A\).
You can assume \(4 \leq n \leq 10^3\) and that the absolute value of each element does not exceed \(10^5\).
outputFormat
Output a single line containing Yes
if there exists a quadruplet (with distinct indices) such that their sum equals \(T\); otherwise, output No
.
6 0
1 0 -1 0 -2 2
Yes