Just Stalling
시간 제한: 1000ms메모리 제한: 512MB출처: USACO 2021 January BronzeBOJ 20975
문제
Farmer John has cows () of heights . His barn has stalls with max height limits (so for example, if , 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?
입력
The first line contains . The second line contains space-separated integers . The third line contains space-separated integers . All heights and limits are in the range .
출력
The number of ways Farmer John can place each cow into a different stall such that the height limit is satisfied for every stall. Note that the large size of the output might require the use of a 64-bit integer, like a "long long" in C++.
예제
예제 1
입력
4 1 2 3 4 2 4 3 4
출력
8
코드를 제출하려면 로그인하세요.