結果

問題 No.944 煎っぞ!
ユーザー kokatsukokatsu
提出日時 2022-11-07 20:50:55
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 17 ms / 3,000 ms
コード長 746 bytes
コンパイル時間 2,079 ms
コンパイル使用メモリ 206,832 KB
実行使用メモリ 8,844 KB
最終ジャッジ日時 2023-09-04 18:53:27
合計ジャッジ時間 5,266 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
8,096 KB
testcase_01 AC 11 ms
7,372 KB
testcase_02 AC 11 ms
7,916 KB
testcase_03 AC 11 ms
8,844 KB
testcase_04 AC 12 ms
7,652 KB
testcase_05 AC 12 ms
7,864 KB
testcase_06 AC 11 ms
7,912 KB
testcase_07 AC 11 ms
8,624 KB
testcase_08 AC 11 ms
7,356 KB
testcase_09 AC 12 ms
7,592 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 4 ms
4,384 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 13 ms
7,752 KB
testcase_21 AC 13 ms
7,420 KB
testcase_22 AC 11 ms
7,384 KB
testcase_23 AC 11 ms
7,916 KB
testcase_24 AC 11 ms
8,168 KB
testcase_25 AC 12 ms
8,184 KB
testcase_26 AC 11 ms
7,592 KB
testcase_27 AC 13 ms
7,416 KB
testcase_28 AC 1 ms
4,384 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 12 ms
7,196 KB
testcase_31 AC 17 ms
7,360 KB
testcase_32 AC 13 ms
8,128 KB
testcase_33 AC 14 ms
8,444 KB
testcase_34 AC 14 ms
7,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    long N;
    readf("%d\n", N);

    auto a = readln.chomp.split.to!(long[]);

    long[] divisors;
    long S = a.sum, d = 1;
    while (d * d <= S) {
        if (S % d == 0) {
            divisors ~= d;
            if (d * d != S) divisors ~= S / d;
        }

        ++d;
    }

    long res;
    foreach (divisor; divisors) {
        bool isOK = true;
        long cnt, num;
        foreach (x; a) {
            num += x;

            if (num == divisor) {
                ++cnt, num = 0;
            }
            else if (num > divisor) {
                isOK = false;
                break;
            }
        }

        isOK &= (num == 0);

        if (isOK) res = max(res, cnt);
    }

    res.writeln;
}
0