View Code of Problem 3686

#include<bits/stdc++.h>
using namespace std;
int jud(int);
int main(){
	int n,x,y;
	cin>>n;
	while(n--){
		cin>>x>>y;
		int num[x] = { },max = 0,f = 0;
		for(int i = 0;i<x;i++)cin>>num[i];
		for(int i = 0;i<x-1;i++){
			max = num[i];
			for(int j = i+1;j<x;j++){
				if(max + num[j] == y){
					f = 1;
					break;
				}
			}
			if(f)break;
		}
		if(f)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3686