View Code of Problem 133

#include<iostream>
using namespace std;
int main(){
	int T;
	cin>>T;
	int n,x;
	int a[999999];
	while(T--){
		
		cin>>n>>x;
		
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		int flag=0;
		for(int i=0;i<n;i++){
			for(int j=i;j<n;j++){
				if(a[i]+a[j]==x&&j!=i){
					flag=1;
					break;
				}
			}
		}
		
		if(flag==1)cout<<"YES"<<'\n';
		else cout<<"NO"<<'\n';
		
	}
}

Double click to view unformatted code.


Back to problem 133