现在的位置: 首页 > 综合 > 正文

Hash的应用,这个题目可以更加理解hash所换来的效率

2013年08月25日 ⁄ 综合 ⁄ 共 855字 ⁄ 字号 评论关闭

题目:

Sum

Time Limit: 9000 MS Memory Limit: 65536 K


Sum

Mr. Jojer is given n numbers and an extra integer x, he wants to know whether there are two numbers whose sum is x.

Input

The input file contains several test cases. The first line of each test case contains two integers, n(<=1000001) and x. From the next line of each test case, there are n numbers.

Output

Each test case corresponds to a line in the output, which is either "YES" if there exists an answer or "NO" if not.

Sample Input

3 3
1 2 3
2 3
1 3

 

 

Sample Output

YES
NO

 

解题代码:

 

用空间换取时间

抱歉!评论已关闭.