import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); sc.nextLine(); while (T-- > 0) { int n = sc.nextInt(); int x = sc.nextInt(); sc.nextLine(); Set<Integer> set = new HashSet<>(); int tag = 0; for (int i = 0; i < n; ++i) { int a = sc.nextInt(); if (set.contains(x - a)) { System.out.println("YES"); tag = 1; break; } set.add(a); } sc.nextLine(); if (tag == 0) System.out.println("NO"); } } } |
Double click to view unformatted code.