PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000115. Đếm cặp phép thuật và thuốc thành công (Successful Pairs of Spells and Potions)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm cặp phép thuật và thuốc thành công (Successful Pairs of Spells and Potions)

Successful Pairs of Spells and Potions

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn spells with strengths sis_i and mm potions with strengths pjp_j. A pair (i,j)(i,j) succeeds exactly when sipj≥Ks_i p_j\ge K. For every spell in its original order, count the potions that form successful pairs. Each pair is considered independently.

Input

The first line contains nn, mm, and KK. The second contains the nn spell strengths; the third contains the mm potion strengths.

Output

Print nn space-separated integers, the successful potion counts for spells in original order.

Subtasks

  • Subtask 1 (20 points): 1≤n≤1001\le n\le 100; 1≤m≤1001\le m\le 100; 1≤si,pj≤1051\le s_i,p_j\le10^5 đối for every phần tử; 1≤K≤10101\le K\le10^{10}.
  • Subtask 2 (30 points): 1≤n≤30001\le n\le 3000; 1≤m≤30001\le m\le 3000; 1≤si,pj≤1051\le s_i,p_j\le10^5 đối for every phần tử; 1≤K≤10101\le K\le10^{10}.
  • Subtask 3 (50 points): 1≤n≤1000001\le n\le 100000; 1≤m≤1000001\le m\le 100000; 1≤si,pj≤1051\le s_i,p_j\le10^5 đối for every phần tử; 1≤K≤10101\le K\le10^{10}.

Examples

Input

3 5 7
5 1 3
1 2 3 4 5

Output

4 0 3

Explanation

For spell strength 55, the products are 5,10,15,20,255,10,15,20,25, so four succeed. For strength 11, products 1,2,3,4,51,2,3,4,5 give zero. For strength 33, products 3,6,9,12,153,6,9,12,15 give three. Output 4 0 3.