View Code of Problem 3686

#include <iostream>
#include <string>
using namespace std;

int main() {
	int t, n, x;
	cin >> t;
	while (t--) {
		cin >> n >> x;
		int girls[100] = { 0 };
		for (int i = 0; i < n; ++i)
			cin >> girls[i];
		int flag = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = i+1; j < n; ++j) {
				if (girls[i] + girls[j] == x)
				{
					cout << "Yes" << endl;
					flag = 1;
					break;
				}
			}
			if (flag) break;
		}
		if (!flag) cout << "No" << endl;
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 3686