結果

問題 No.944 煎っぞ!
ユーザー GrayCoder
提出日時 2019-12-07 10:26:48
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 457 ms / 3,000 ms
コード長 553 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 20,456 KB
最終ジャッジ日時 2024-12-24 18:38:20
合計ジャッジ時間 5,892 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    A = map(int, input().split())

    if N == 1:
        print(1)
        return

    a = tuple(accumulate(A))
    for n in range(N, 0, -1):
        d, m = divmod(a[-1], n)
        if m:
            continue
        ans = 0
        for ai in a[::-1]:
            if ai == d * n:
                ans += 1
                n -= 1
                if not n:
                    print(ans)
                    return


main()
0