結果
| 問題 |
No.944 煎っぞ!
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-26 15:43:08 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 67 ms / 3,000 ms |
| コード長 | 967 bytes |
| コンパイル時間 | 352 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 82,432 KB |
| 最終ジャッジ日時 | 2025-03-26 15:43:13 |
| 合計ジャッジ時間 | 4,521 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
ソースコード
def main():
import sys
input = sys.stdin.read().split()
N = int(input[0])
a = list(map(int, input[1:N+1]))
sum_S = sum(a)
def get_divisors(s):
divisors = set()
for i in range(1, int(s**0.5) + 1):
if s % i == 0:
divisors.add(i)
divisors.add(s // i)
return divisors
divisors = get_divisors(sum_S)
candidates = [d for d in divisors if d <= N]
candidates.sort(reverse=True)
for d in candidates:
t = sum_S // d
current_sum = 0
cnt = 0
possible = True
for num in a:
current_sum += num
if current_sum == t:
cnt += 1
current_sum = 0
elif current_sum > t:
possible = False
break
if possible and current_sum == 0 and cnt == d:
print(d)
return
print(1)
if __name__ == '__main__':
main()
lam6er