結果
問題 | No.944 煎っぞ! |
ユーザー | nebukuro09 |
提出日時 | 2019-12-07 13:30:03 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 15 ms / 3,000 ms |
コード長 | 958 bytes |
コンパイル時間 | 792 ms |
コンパイル使用メモリ | 117,068 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-22 03:23:46 |
合計ジャッジ時間 | 2,114 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdio; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!int).array; auto S = A.sum; int[] P; for (int i = 1; i * i <= S; ++i) { if (S % i == 0) { P ~= i; if (i * i != S) { P ~= S / i; } } } int ans = 0; foreach (p; P) { int cnt = 0; int tmp = 0; bool ok = true; foreach (a; A) { if (tmp + a > p) { ok = false; break; } else if (tmp + a == p) { cnt += 1; tmp = 0; } else { tmp += a; } } if (ok) { ans = max(ans, cnt); } } ans.writeln; }