結果

問題 No.944 煎っぞ!
ユーザー ronpooronpoo
提出日時 2023-11-06 13:04:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 3,000 ms
コード長 913 bytes
コンパイル時間 822 ms
コンパイル使用メモリ 81,908 KB
実行使用メモリ 94,304 KB
最終ジャッジ日時 2023-11-06 13:04:27
合計ジャッジ時間 5,358 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
85,076 KB
testcase_01 AC 62 ms
85,076 KB
testcase_02 AC 64 ms
85,076 KB
testcase_03 AC 61 ms
85,076 KB
testcase_04 AC 64 ms
87,256 KB
testcase_05 AC 61 ms
85,076 KB
testcase_06 AC 63 ms
85,076 KB
testcase_07 AC 62 ms
85,076 KB
testcase_08 AC 63 ms
85,076 KB
testcase_09 AC 62 ms
85,076 KB
testcase_10 AC 43 ms
59,988 KB
testcase_11 AC 46 ms
65,300 KB
testcase_12 AC 46 ms
64,220 KB
testcase_13 AC 37 ms
53,584 KB
testcase_14 AC 46 ms
65,304 KB
testcase_15 AC 45 ms
62,168 KB
testcase_16 AC 37 ms
53,584 KB
testcase_17 AC 38 ms
53,584 KB
testcase_18 AC 45 ms
65,304 KB
testcase_19 AC 45 ms
64,968 KB
testcase_20 AC 65 ms
87,452 KB
testcase_21 AC 64 ms
87,452 KB
testcase_22 AC 63 ms
85,056 KB
testcase_23 AC 61 ms
85,056 KB
testcase_24 AC 65 ms
87,368 KB
testcase_25 AC 62 ms
85,056 KB
testcase_26 AC 62 ms
85,056 KB
testcase_27 AC 68 ms
88,760 KB
testcase_28 AC 36 ms
53,584 KB
testcase_29 AC 37 ms
53,584 KB
testcase_30 AC 63 ms
87,476 KB
testcase_31 AC 102 ms
94,224 KB
testcase_32 AC 90 ms
94,224 KB
testcase_33 AC 86 ms
94,304 KB
testcase_34 AC 86 ms
94,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))


# 約数列挙
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def bisec(x):
    l = 0
    r = len(accm)
    while r - l > 1:
        m = (l + r) // 2
        if accm[m] >= x:
            r = m
        else:
            l = m
    if accm[r] == x:
        return True
    else:
        return False

sm = 0
accm  = [0]
for i in range(N):
    accm.append(accm[i] + A[i])
    sm += A[i]
    
md = make_divisors(sm)
md.pop()

ans = 1
for d in md:
    num = sm // d
    x = 0
    for i in range(1, num):
        x = d * i
        if not bisec(x):
            break
    else:
        ans = num
        break
print(ans)
0