View Code of Problem 3686

#include<iostream>
using namespace std;
int main()
{
	  int t,n,x;
	cin>>t;
	while(t--)
	{
		cin>>n>>x;
		int array[n],flag=0;
		for(int i=0;i<n;i++)
		  cin>>array[i];
		  
		for(int j=0;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(array[j]+array[k]==x)
				  {
				  flag++;
				  break;}
			}
		}
		if(flag==0) cout<<"NO"<<endl;
		  else cout<<"YES"<<endl;
		
	 } 
	
}

Double click to view unformatted code.


Back to problem 3686