View Code of Problem 3686

#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin>>n;
	int a,b;
	int flag;
	for(int i=0;i<n;i++){
		scanf("%d %d",&a,&b);
		flag=0;
		vector<int> o;
		unordered_map<int,int> k;
		int op;
		for(int j=0;j<a;j++){
			scanf("%d",&op);
			o.push_back(op);
			k[op]++;
		}
		for(int j=0;j<a;j++){
			if((k[b-o[j]]==1&&o[j]*2!=b)||k[b-o[j]]>1){
					cout<<"YES"<<endl;
					flag=1;
					break;
			}

		}
		if(flag==0){
			cout<<"NO"<<endl;
		}
	}
}

Double click to view unformatted code.


Back to problem 3686