Just Stalling#11197

Just Stalling

1 Sekunde
128 Megabyte
Schwer

Farmer John has cows of heights a_1, \ldots, a_n. His barn has stalls with max height limits b_1, \ldots, b_n (so for example, if b_5 = 17, then a cow of height at most can reside in stall ). In how many distinct ways can Farmer John arrange his cows so that each cow is in a different stall, and so that the height limit is satisfied for every stall?

Eingabe

The first line contains n\:(1 \le n \le 20). The second line contains integers a_1, a_2, \ldots, a_n. The third line contains integers b_1, b_2, \ldots, b_n. All heights and limits are in the range [1, 10^9].

Ausgabe

Print the number of ways Farmer John can place each cow into a different stall such that the height limit is satisfied for every stall.

Beispiele

Beispiel 1

Loading
Loading

Notiz

In this example, we cannot place the third cow into the first stall since a_3 = 3 > b_1 = 2. Similarly, we cannot place the fourth cow into the first or third stalls. One of 8 ways to satisfy the height limits is to assign cow to stall , cow to stall , cow to stall , and cow to stall .