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

32368번 - Chocolate Bar Partition 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB157650.000%

문제

Maxwell has a chocolate bar that he wants to share with his friends. The chocolate bar can be represented as a 2 by N array of integers Ti,j, the tastiness of each square. Maxwell would like to split the entire chocolate bar into connected parts such that the average (mean) tastiness of the chocolate bar is the same for each part. Maxwell would like to know what is the maximum number of connected parts he can split his chocolate bar into as described above.

A part is considered connected if you can visit every cell by moving up, down, left or right.

입력

The first line of input will consist of one positive integer N, representing the length of the chocolate bar.

The second line of input contains N spaced integers representing the top row of the chocolate bar where the j-th integer from the left represents T1,j.

Similarly, the third line of input contains N spaced integers representing the bottom row of the chocolate bar where the j-th integer from the left represents T2,j.

출력

Output a single integer, representing the maximum number of connected parts Maxwell can split his chocolate bar into.

제한

서브태스크

Subtask Score Bounds on N Bounds on Ti,j
1 2 N = 2 0 ≤ Ti,j ≤ 5
2 2 1 ≤ N ≤ 8 0 ≤ Ti,j ≤ 20
3 1 1 ≤ N ≤ 20 0 ≤ Ti,j ≤ 20
4 2 1 ≤ N ≤ 100 0 ≤ Ti,j ≤ 20
5 2 1 ≤ N ≤ 1 000 0 ≤ Ti,j ≤ 100
6 3 1 ≤ N ≤ 2 000 0 ≤ Ti,j ≤ 100 000
7 3 1 ≤ N ≤ 200 000 0 ≤ Ti,j ≤ 100 000 000

예제 입력 1

2
5 4
6 5

예제 출력 1

2

An example of how to split this chocolate bar optimally into 2 parts is to have the bottom right corner as its own part and the rest of the chocolate as the second part, as shown below.

Each piece will have an average tastiness of 5.

예제 입력 2

5
1 0 1 2 0
0 2 0 3 1

예제 출력 2

5

One way to get the optimal split is shown in the following picture:

Note that each piece has an average tastiness of 1.

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2024 > CCC 2024 Senior Division 5번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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