1230 element search, 1230 search

Source: Internet
Author: User

1230 element search, 1230 search
1230 element search

 

Time Limit: 1 s space limit: 128000 KB title level: Diamond Title Description Description

N positive integers are given, and then m queries are given. Each query is an integer, asking whether the integer has appeared in n positive integers.

Input description Input Description

The first line has two integers, n and m.

N positive integers in the second row (1 <=n <= 100000)

M integers in the third row (1 <= m <= 100000)

Output description Output Description

A total of m rows. If YES, YES is output; otherwise, NO is output.

Sample Input Sample Input

4 2

2 1 3 4

1 9

Sample output Sample Output

YES

NO

Data range and prompt Data Size & Hint

All data cannot exceed 10 ^ 8

CATEGORY tag Tags click here to expand

Well, I feel that this question is quite satisfactory.

The idea of Bucket sorting can also be used.

Can be used with set

I am still down-to-earth (lazy) writing, hash_map

 

 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.