View Code of Problem 133

# include <stdio.h>
  void f(int n,int x)
  {
	  int i,b[100010]={0},a[100010];
	  for(i=1;i<=n;i++)
	  {
		  scanf("%d",&a[i]);
			  if(a[i]>=0)
			  {
				  if(b[a[i]]==0)
					  b[a[i]]=1;
				  else
					  b[a[i]]=2;
			  }
			  else
			  {
				  if(b[a[i]]==0)
					  b[a[i]]=-1;
				  else
					  b[a[i]]=-2;
			  }
	  }
	  if(x%2==0&&a[x/2]==2)
		  printf("YES\n");
	  else
	  {
	   for(i=1;i<=n;i++)
		  if((b[x-a[i]]==1||b[a[i]-x]==-1)&&(x-a[i])!=a[i])
		  break;
		  if(i<n)
			  printf("YES\n");
		  else
			  printf("NO\n");
	  }
  }
  main()
  {
	  int t,n,x;
	  scanf("%d",&t);
	  while(t--)
	  {
		  scanf("%d%d",&n,&x);
		  f(n,x);
	  }
  }

Double click to view unformatted code.


Back to problem 133