問題一覧 > 通常問題

No.944 Roast It!

レベル : / AI推定難易度 : 750 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 199
作問者 : ganariya / テスター : nmnmnmnmnmnmnm
お気に入りにしたユーザー ProblemId : 2628 / 自分の提出
問題文最終更新日: 2019-12-08 00:05:12
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
Advent Calendar Contest 2019 (順位表) の他の問題:

Problem Statement

The virtual YouTuber Uzuki Rou loved coffee beans. She loved them so much that she even roasted the beans herself. Each coffee bean in this world has a "deliciousness" represented by a positive integer, which indicates how delicious the bean is.

Uzuki Rou has a total of $N$ coffee beans, represented by a sequence $a$. The deliciousness of the $i$-th coffee bean from the left is $a_i$.

Since coffee beans in the sequence $a$ with varying deliciousness would contain a lot of bitterness, Uzuki Rou has decided to freely perform an operation any number of times so that all coffee beans have equal deliciousness.

The operation that can be performed is as follows.

  • Let $K$ be the current number of elements in the sequence $a$. Roast the $i(1{\leq}i{\leq}K-1)$-th coffee bean from the left and the $i+1$-th coffee bean, which are $2$ adjacent coffee beans, into $1$ bean. The deliciousness of the newly created coffee bean is $a_i+a_{i+1}$. Note that this can only be performed when $K>1$ (since adjacent coffee beans are required).

By repeating the above operation, Uzuki Rou wants to make the deliciousness of all coffee beans equal while maximizing the number $R$ of coffee beans remaining at the end of the operations. Find the maximum number $R$ of coffee beans remaining at the end of the operations.

Input

$N$
$a_1 \ a_2 \ ...\ a_N$

  • All inputs are integers
  • $1{\leq}N{\leq}10^5$
  • $1{\leq}a_i{\leq}10^2$

Output

Print a newline at the end.

Sample

Sample 1
Input
8
5 2 2 3 1 1 4 3
Output
3

Uzuki Rou has $8$ coffee beans.

By repeating the operation of roasting $2$ adjacent coffee beans together, the arrangement can be made into $a = (7, 7, 7)$, and this gives the maximum number of coffee beans remaining at the end of the operations, $3$.

Combining all of them gives $a = (21)$, but only $1$ bean remains, so the answer is $3$.

Sample 2
Input
1
50
Output
1

From the start, no further operations can be performed.

Sample 3
Input
60
36 45 67 64 100 2 3 22 52 64 9 22 53 63 45 60 56 26 68 33 87 23 91 81 71 34 37 91 51 26 44 76 93 1 34 100 3 22 53 23 61 8 85 90 49 6 40 45 66 80 36 32 21 88 40 42 78 97 99 6 
Output
3

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。