Logo
(追記) (追記ここまで)

20975번 - Just Stalling 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB72141737759.746%

문제

Farmer John has $N$ cows (1ドル\le N \leq 20$) of heights $a_1 \ldots a_N$. His barn has $N$ stalls with max height limits $b_1 \ldots b_N$ (so for example, if $b_5 = 17,ドル then a cow of height at most 17ドル$ can reside in stall 5ドル$). 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 $N$. The second line contains $N$ space-separated integers $a_1,a_2,\ldots,a_N$. The third line contains $N$ space-separated integers $b_1,b_2,\ldots,b_N$. All heights and limits are in the range $[1,10^9]$.

출력

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

예제 출력 1

8

In this example, we cannot place the third cow into the first stall since 3ドル=a_3>b_1=2$. Similarly, we cannot place the fourth cow into the first or third stalls. One way to satisfy the height limits is to assign cow 1ドル$ to stall 1ドル,ドル cow 2ドル$ to stall 2ドル,ドル cow 3ドル$ to stall 3ドル,ドル and cow 4ドル$ to stall 4ドル$.

힌트

출처

Olympiad > USA Computing Olympiad > 2020-2021 Season > USACO 2021 January Contest > Bronze 3번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /