View Code of Problem 3686

#include<stdio.h>
#include<string.h> 
int a[10000000],b[1000000];
int main()
{
	int t,i,j,n,x;
	scanf("%d",&t);
	while(t--) 
	{
		memset(a,0,sizeof(a));
        scanf("%d%d",&n,&x);
		for(j=0;j<n;j++)
		{
			scanf("%d",&b[j]);
			a[b[j]]++; 
		}
		for(j=0;j<n;j++)
		{
				if(x>b[j])
				
				 {
				   if(a[x-b[j]]!=0&&x!=(2*b[j]))
				    	{
						printf("YES\n");
				     	break;
				         }
				  else if(a[x-b[j]]>1)
						{
							printf("YES\n");
						    break;
						}
	               }
         	}
         	if(j==n)
			printf("NO\n");
 
   }
   return 0;
}

Double click to view unformatted code.


Back to problem 3686