View Code of Problem 133

#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
	int t,i;
	int max;
	int m,b,sum,k;
	int a[10000010],c[10000010];
	scanf("%d",&t);
	while(t--){
		scanf("%d%d",&m,&sum);
		for(i=0;i<=10000010;i++)
			a[i]=0;
		k=0;
		for(i=0;i<m;i++){
			scanf("%d",&b);
			c[i]=b;
			a[b]=1;
		}
		for(i=0;i<m;i++)
			if(a[c[i]]==1 && a[sum-c[i]]==1){
				k=1;break;
			}
		printf(k==1?"YES\n":"NO\n");
	}
}

Double click to view unformatted code.


Back to problem 133