All problems

Problem 574

Successful Pairs of Spells and Potions

Medium · 20 pts · Array, Binary Search, Sorting

Problem

You have N spells and M potions with given strengths. A spell and a potion form a successful pair if the product of their strengths is at least S. For every spell, count the potions it forms a successful pair with. Sort the potions once; for a spell of strength x, the successful potions are exactly those with strength at least ceil(S / x), which one binary search finds. Products can reach 10^10, so use 64-bit arithmetic.

Input

The first line contains N, M and S. The second line contains the N spell strengths. The third line contains the M potion strengths.

Output

Print N integers separated by spaces: the count for each spell.

Constraints

1 <= N, M <= 100000; 1 <= strengths <= 100000; 1 <= S <= 10^10

Example input

3 5 7
5 1 3
1 2 3 4 5

Example output

4 0 3

Explanation

With spells 5 1 3, potions 1 2 3 4 5 and S = 7: spell 5 succeeds with potions 2, 3, 4 and 5 (5 × 1 = 5 is too small), spell 1 with none, and spell 3 with 3, 4 and 5. The answer is 4 0 3.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Pairs of Songs With Total Durations Divisible by 60 Next: Maximum Distance Between a Pair of Values