結果

問題 No.944 煎っぞ!
ユーザー FromBooskaFromBooska
提出日時 2023-03-07 13:17:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 3,000 ms
コード長 838 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,924 KB
実行使用メモリ 81,184 KB
最終ジャッジ日時 2023-10-18 05:29:27
合計ジャッジ時間 4,735 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
78,876 KB
testcase_01 AC 57 ms
78,876 KB
testcase_02 AC 58 ms
78,876 KB
testcase_03 AC 60 ms
78,876 KB
testcase_04 AC 62 ms
78,876 KB
testcase_05 AC 58 ms
78,876 KB
testcase_06 AC 60 ms
78,876 KB
testcase_07 AC 60 ms
78,876 KB
testcase_08 AC 59 ms
78,876 KB
testcase_09 AC 59 ms
78,876 KB
testcase_10 AC 44 ms
60,180 KB
testcase_11 AC 48 ms
65,192 KB
testcase_12 AC 47 ms
62,228 KB
testcase_13 AC 38 ms
53,572 KB
testcase_14 AC 46 ms
63,000 KB
testcase_15 AC 45 ms
62,228 KB
testcase_16 AC 38 ms
53,572 KB
testcase_17 AC 39 ms
53,572 KB
testcase_18 AC 49 ms
65,196 KB
testcase_19 AC 47 ms
64,860 KB
testcase_20 AC 61 ms
79,092 KB
testcase_21 AC 61 ms
79,092 KB
testcase_22 AC 60 ms
79,004 KB
testcase_23 AC 60 ms
79,004 KB
testcase_24 AC 61 ms
79,004 KB
testcase_25 AC 60 ms
79,004 KB
testcase_26 AC 60 ms
79,004 KB
testcase_27 AC 65 ms
81,184 KB
testcase_28 AC 38 ms
53,572 KB
testcase_29 AC 38 ms
53,572 KB
testcase_30 AC 60 ms
79,116 KB
testcase_31 AC 97 ms
81,008 KB
testcase_32 AC 66 ms
81,064 KB
testcase_33 AC 68 ms
81,164 KB
testcase_34 AC 66 ms
81,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 最後の数字はsumAの約数にしかならない、その個数はsumA//約数
# 約数列挙して小さい約数から試す、Aの前からその約数和にしていけるか

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

def 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]

sumA = sum(A)
divs = divisors(sumA)
ans = 0
for d in divs:
    s = 0
    count = 0
    for a in A:
        if s+a < d:
            s += a
        elif s+a == d:
            s = 0
            count += 1
        elif s+a > d:
            count = -1
            break
    ans = max(ans, count)
    
print(ans) 
0