結果

問題 No.944 煎っぞ!
ユーザー nebukuro09nebukuro09
提出日時 2019-12-07 13:30:03
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 16 ms / 3,000 ms
コード長 958 bytes
コンパイル時間 647 ms
コンパイル使用メモリ 105,860 KB
実行使用メモリ 6,560 KB
最終ジャッジ日時 2023-09-04 03:42:53
合計ジャッジ時間 2,236 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,560 KB
testcase_01 AC 10 ms
5,980 KB
testcase_02 AC 10 ms
5,516 KB
testcase_03 AC 9 ms
5,104 KB
testcase_04 AC 9 ms
5,304 KB
testcase_05 AC 9 ms
5,048 KB
testcase_06 AC 10 ms
6,008 KB
testcase_07 AC 9 ms
5,088 KB
testcase_08 AC 9 ms
5,132 KB
testcase_09 AC 10 ms
6,348 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 10 ms
5,472 KB
testcase_21 AC 10 ms
5,168 KB
testcase_22 AC 10 ms
6,172 KB
testcase_23 AC 10 ms
5,652 KB
testcase_24 AC 9 ms
5,380 KB
testcase_25 AC 9 ms
6,116 KB
testcase_26 AC 10 ms
5,912 KB
testcase_27 AC 12 ms
5,036 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 11 ms
5,404 KB
testcase_31 AC 16 ms
5,600 KB
testcase_32 AC 11 ms
5,020 KB
testcase_33 AC 11 ms
5,188 KB
testcase_34 AC 12 ms
5,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
}
0