RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
R03609

S5. Chocolate Bar Partition

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

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 \(T_{i,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
\(T_{1,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
\(T_{2,j}\).

출력 형식

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

서브태스크
서브태스크점수설명

1

13점

\(N=2\)\(0 \le T_{i,j} \leq 5\)

2

13점

\(1 \le N \le 8\)\(0 \le T_{i,j} \leq 20\)

3

6점

\(1 \le N \le 20\)\(0 \le T_{i,j} \leq 20\)

4

13점

\(1 \le N \le 100\)\(0 \le T_{i,j} \leq 20\)

5

13점

\(1 \le N \le 1\ 000\)\(0 \le T_{i,j} \leq 100\)

6

21점

\(1 \le N \le 2\ 000\)\(0 \le T_{i,j} \leq 100\ 000\)

7

21점

\(1 \le N \le 200\ 000\)\(0 \le T_{i,j} \leq 100\ 000\ 000\)

예제 1
입력
2
5 4
6 5
출력
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
출력
5
설명

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

Note that each piece has an average tastiness of \(1\).

문제 정보

생성자가 기록되지 않았습니다.

출처 CCC 2024 Senior

평가 및 의견

S5. Chocolate Bar Partition

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

S5. Chocolate Bar Partition

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8