View Code of Problem 133

#include <math.h>
int main()
{
    int t;
    scanf("%d",&t);
	while(t--)
	{
	   int n,x;
	   int flag=0;
	   scanf("%d %d",&n,&x);
	   int a[n],i,j;
	   for(i=0;i<n;i++)
	     scanf("%d",&a[i]);
	   for(i=0;i<n-1;i++)
	   {
	   	 for(j=i+1;j<n;j++)
	   	 {
	   		if(a[i]+a[j]==x)
	   		{
	   		  printf("YES\n");
			  flag=1;	
			  break; 
			}
		 }
		 if(flag==1)
		   break;
	   }
	   if(flag==0)
	     printf("NO\n");
	}
}

Double click to view unformatted code.


Back to problem 133