Less Than X

View as PDF

Submit solution

Points: 1
Time limit: 2.0s
Memory limit: 488M

Author:
Problem type

Problem Statement

You are given a list x of n integers x = [x_1, x_2, ..., x_n]. You are also given q queries, for each query, you are give some integer k should output the number of unique integers less than k in x.

Input Format

Your first line will contain n and q. Your next line will contain n space-separated integers x_1, x_2, ..., x_n. Your next q lines will contain one integer each.

Output Format

For each query, you should output an integer representing the number of UNIQUE (non-duplicate) numbers (strictly) less than it in x.

Constraints

  • 1 \leq n, q \leq 10^5
  • -10^9 \leq x_i \leq 10^9 ## Sample Cases
Input 1
10 3
1 4 4 5 6 -2 4 2 5 10
14
5
7
Output 1
7
4
6
Explanation 1

There are 7 integers less than 14, being -2, 1, 2, 4, 5, 6, 10. There are 4 integers less than 5, being -2, 1, 2, 4. There are 6 integers less than 7, being -2, 1, 2, 4, 5, 6.


Comments

There are no comments at the moment.