View Code of Problem 133

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	int t;
	scanf("%d",&t);
	while(t--){
		int n,x;
		scanf("%d %d",&n,&x);
		int i,j;
		int a[n];
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		int flag;
		for(i=0;i<n-1;i++)
		{
			flag=0;
			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");
	}
	return 0;	
}

Double click to view unformatted code.


Back to problem 133