結果
問題 |
No.944 煎っぞ!
|
ユーザー |
![]() |
提出日時 | 2023-03-07 13:17:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 83 ms / 3,000 ms |
コード長 | 838 bytes |
コンパイル時間 | 338 ms |
コンパイル使用メモリ | 81,664 KB |
実行使用メモリ | 80,128 KB |
最終ジャッジ日時 | 2024-09-18 02:07:56 |
合計ジャッジ時間 | 3,659 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
# 最後の数字は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)