QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22652. 晨練

Statistics

每天早晨 Farmer John 領牛出牛棚晨練(健康牛產奶更多)。必須排成並列且一樣長的兩列。他劃出 $2 \times N$ ($1 \le N \le 100$) 牧場長條,可視為 $2N$ 個方格。正以為準備好了,卻發現忽略部分格的樹,牛不能站樹上。

晨練要求緊密聚在一起,不能用牧場其他部分。他只能分成若干 $2 \times [某個數]$ 的組,逐組鍛鍊。他喜歡大組,因此求一次最多帶多少頭,只要占連續的 $2 \times K$ 子長條 ($K \le N$)。

輸入格式

  • 第 1 列:整數 $N$。
  • 第 $1..N+1$ 列:每列兩個空格分隔整數,描述 $1 \times 2$ 長條。有樹為 1,無樹為 0;範例可說明。

輸出格式

  • 第 1 列:整數,一次可晨練的奶牛數。

範例

輸入格式 1

7
0 0
1 0
1 1
0 0
0 0
0 0
0 1

輸出格式 1

6

說明

輸入說明

給出有四棵樹的 $2\times7$ 長條。

輸出說明

最大連續無樹子長條為 $2\times3$,可容 $2\times3 = 6$ 頭。

題目作者:Percy Liang,2004。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.