View Code of Problem 133

#include <stdio.h>
#include <string.h>
#include<math.h>
#include<stdlib.h>

int main(){
	
	int t;
	scanf("%d",&t);
	while(t--){
		int n,x,flag=1;
		scanf("%d%d",&n,&x);
		int s[n];
		for(int i=0;i<n;i++){
			scanf("%d",&s[i]);
		}
		for(int i=0;i<n;i++){
			for(int j=i;j<n;j++){
				if(s[i]+s[j]==x){
					flag=1;
					break;
				}
				else{
					flag=0;
				}
			}
			if(flag) break;
		}
		if(flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 133