View Code of Problem 133

#include<stdio.h>
int main()
{
	int t, n, x, s[100010], i, j, a;
	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++)
		{
			a = x - s[i];
			for (j = 0; j < n; j++)
			{
				if (i != j && s[j] == a)
				{
					printf("YES\n");
					goto stop;
				}
			}
		}
		printf("NO\n");
stop:;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 133