View Code of Problem 133

#include<stdio.h>
int main()
{
	int t, n, x, s[100010], i, j;
	scanf("%d", &t);
	while(t--)
	{
		scanf("%d %d", &n, &x);
		for (i = 0; i < n; i++)
			scanf("%d", &s[i]);
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
			{
				if (i != j && s[i] + s[j] == x)
				{
					printf("YES\n");
			     	return 0;
				}
			}
			printf("NO\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 133