LCC '22 Contest 1 J3 - Appalling Attire

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

After finally finishing his ICS homework, Max decides to check his M friends' (1 \le M \le 2\times10^5) rankings for the costume contest, since the full rankings have just been posted on the school's website (maclyonsden.com #shamelessplug).

However, Max suddenly realizes that the rankings are completely wrong! Not only are the scores in completely random order, they aren't even ranked!

It's too late at night for Max to try and alert someone about the mistake, but he really wants to know how much better he is so he can brag how his friends did in the contest.

Luckily, Max knows the scores of all of his friends, so he decides to ask you to write a program to output his friend's rankings (since his brain is very burnt out from his ICS homework).

Given that the higher the costume score, the better the ranking, and that 1 is the highest rank (1 is a better ranking than 2, etc.), can you output all the rankings of his friends, in the order that they were given?

Note: If two contestants have the same score, they will share the same rank, and the next contestant with a lower score will have the rank equivalent to the number of contestants who have a score higher than them +1.

Constraints

Subtask 1 [20%]

N, M \le 1000

Subtask 2 [80%]

No additional constraints.

Input Specification

The first line will contain two integers, N (1 \le N \le 2\times10^5) and M, the number of contestants in the contest and the number of friends that Max has.

The next N lines will each contain one integer R_i (0 \le R_i \le 10^5), the score of the ith contestant.

The next M lines will each contain one integer S_i (0 \le S_i \le 10^5), the score of Max's ith friend.

Every friend is guaranteed to be one of the contestants.

Output Specification

Output M lines, each containing one integer K_i (1\le K_i \le 10^5), the ranking of Max's ith friend.

Sample Input 1

5 3
15
62
44
12
62
62
62
15

Sample Output 1

1
1
4

Comments

There are no comments at the moment.