View Code of Problem 3686

#include <cstdio>
#include <iostream>

using namespace std;

int main(){
	int t;
	cin>>t;
	for(int i=0;i<t;i++){
		int n,x;
		cin>>n>>x;
		int kk[n]={0};
		for(int j=0;j<n;j++){
			cin>>kk[j];
		}
		int flag=0;
		for(int j=0;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(kk[j]+kk[k]==x){
					flag=1;
					break;
				}
			}
		}
		if(flag){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
} 

Double click to view unformatted code.


Back to problem 3686