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

31768번 - Smaller Averages 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB81423352.381%

문제

Bessie has two arrays of length $N$ (1ドル \le N \le 500$). The $i$-th element of the first array is $a_i$ (1ドル \le a_i \le 10^6$) and the $i$-th element of the second array is $b_i$ (1ドル \le b_i \le 10^6$).

Bessie wants to split both arrays into non-empty subarrays such that the following is true.

  1. Every element belongs in exactly 1 subarray.
  2. Both arrays are split into the same number of subarrays. Let the number of subarrays the first and second array are split into be $k$ (i.e. the first array is split into exactly $k$ subarrays and the second array is split into exactly $k$ subarrays).
  3. For all 1ドル \le i \le k,ドル the average of the $i$-th subarray on the left of the first array is less than or equal to the average of the $i$-th subarray on the left of the second array.

Count how many ways she can split both arrays into non-empty subarrays while satisfying the constraints modulo 10ドル^9+7$. Two ways are considered different if the number of subarrays are different or if some element belongs in a different subarray.

입력

The first line contains $N$.

The next line contains $a_1,a_2,...,a_N$.

The next line contains $b_1,b_2,...,b_N$.

출력

Output the number of ways she can split both arrays into non-empty subarrays while satisfying the constraints modulo 10ドル^9+7$.

제한

예제 입력 1

2
1 2
2 2

예제 출력 1

2

The two valid ways are:

  1. Split the first array into $[1],[2]$ and the second array into $[2],[2]$.
  2. Split the first array into $[1,2]$ and the second array into $[2,2]$.

예제 입력 2

3
1 3 2
2 2 2

예제 출력 2

3

The three valid ways are:

  1. Split the first array into $[1,3],[2]$ and the second array into $[2,2],[2]$.
  2. Split the first array into $[1,3],[2]$ and the second array into $[2],[2,2]$.
  3. Split the first array into $[1,3,2]$ and the second array into $[2,2,2]$.

예제 입력 3

5
2 5 1 3 2
2 1 5 2 2

예제 출력 3

1

The only valid way is to split the first array into $[2],[5,1,3],[2]$ and the second array into $[2],[1,5],[2,2]$.

예제 입력 4

7
3 5 2 3 4 4 1
5 3 5 3 3 4 1

예제 출력 4

140

힌트

출처

Olympiad > USA Computing Olympiad > 2023-2024 Season > USACO 2024 US Open Contest > Gold 3번

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

출처

대학교 대회

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

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