[Solution] 3SUM Closure Codeforces Solution | Codeforces Problem Solution 2022
You are given an array of length . The array is called 3SUM-closed if for all distinct indices , , , the sum is an element of the array. More formally, is 3SUM-closed if for all integers , there exists some integer such that .
Determine if is 3SUM-closed.
The first line contains an integer () — the number of test cases.
The first line of each test case contains an integer () — the length of the array.
The second line of each test case contains integers () — the elements of the array.
It is guaranteed that the sum of across all test cases does not exceed .
For each test case, output "YES" (without quotes) if is 3SUM-closed and "NO" (without quotes)
otherwise.
You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).
No comments:
Post a Comment