結果
| 問題 | 
                            No.944 煎っぞ!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-05-11 00:04:48 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 107 ms / 3,000 ms | 
| コード長 | 546 bytes | 
| コンパイル時間 | 481 ms | 
| コンパイル使用メモリ | 82,280 KB | 
| 実行使用メモリ | 95,040 KB | 
| 最終ジャッジ日時 | 2024-11-27 03:22:02 | 
| 合計ジャッジ時間 | 4,939 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 35 | 
ソースコード
from bisect import bisect_left
n = int(input())
A = list(map(int, input().split()))
sumA = sum(A)
accumA = [0]
for i in range(n):
    accumA.append(accumA[-1] + A[i])
for i in range(n, 0, -1):
    if sumA % i != 0:
        continue
    res = sumA // i
    cnt = 0
    idx = 0
    pre_idx = 0
    while pre_idx < n:
        idx = bisect_left(accumA, res + accumA[pre_idx])
        if idx == n + 1 or accumA[idx] != res + accumA[pre_idx]:
            break
        cnt += 1
        pre_idx = idx
    if cnt == i:
        print(i)
        exit()