View Code of Problem 3686

#include <iostream>
#include <vector>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n, money,flag=0;
		cin >> n >> money;
		vector<int> gf;
		for (int i = 0; i < n; i++)
		{
			int temp;
			cin >> temp;
			gf.push_back(temp);
		}
		for (int i = 0; i < gf.size()-1; i++)
		{
			if (gf[i] >= money)continue;
			for (int j = i+1; j < gf.size(); j++)
			{
				if (gf[i] + gf[j] == money) {
					cout << "Yes";
					flag = 1;
					break;
				}
			}
			if (flag == 1)break;
		}
		if (flag == 0)cout << "No";
		if (t != 0)cout << endl;

	}
}

Double click to view unformatted code.


Back to problem 3686