Delicious Apples
InterviewTime limit2sMemory limit2048 MB
For each query p, count the apples with taste at least p that have the largest size among those apples.
- Level
Easy3 of 10
- Topics
- Sorting, Binary search
- Solved
- No attempts yet
Problem
There are apples numbered 1 through . The taste of apple is , and its size is .
You must answer queries. Each query gives an integer , and you must print the number of apples with the largest size among those whose taste is at least . If no apple satisfies the condition, print 0.
Input
The first line contains and , separated by a space.
The second line contains the tastes , separated by spaces.
The third line contains the sizes , separated by spaces.
Each of the next lines contains one integer .
Output
Print lines. For each , print the number of apples with the largest size among those with taste at least , one per line, in order.