結果

問題 No.944 煎っぞ!
ユーザー noriocnorioc
提出日時 2020-03-22 05:38:04
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 17 ms / 3,000 ms
コード長 805 bytes
コンパイル時間 2,678 ms
コンパイル使用メモリ 164,900 KB
実行使用メモリ 7,280 KB
最終ジャッジ日時 2023-09-04 06:24:54
合計ジャッジ時間 4,450 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,132 KB
testcase_01 AC 11 ms
6,128 KB
testcase_02 AC 12 ms
7,148 KB
testcase_03 AC 11 ms
6,128 KB
testcase_04 AC 12 ms
6,872 KB
testcase_05 AC 12 ms
6,384 KB
testcase_06 AC 12 ms
6,844 KB
testcase_07 AC 11 ms
6,104 KB
testcase_08 AC 11 ms
6,080 KB
testcase_09 AC 12 ms
6,584 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 4 ms
5,884 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 13 ms
7,280 KB
testcase_21 AC 12 ms
6,096 KB
testcase_22 AC 11 ms
7,152 KB
testcase_23 AC 11 ms
6,880 KB
testcase_24 AC 11 ms
6,388 KB
testcase_25 AC 11 ms
6,460 KB
testcase_26 AC 10 ms
6,088 KB
testcase_27 AC 12 ms
6,936 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 13 ms
6,136 KB
testcase_31 AC 17 ms
6,356 KB
testcase_32 AC 14 ms
7,184 KB
testcase_33 AC 14 ms
6,376 KB
testcase_34 AC 14 ms
6,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

int calc(int[] a) {
    int sum = a.sum;
    auto acc = a.cumulativeFold!"a + b".array.assumeSorted;
    for (int i = 0; i < acc.length; i++) {
        if (sum % acc[i] == 0) {
            bool ok = true;
            for (int j = acc[i] * 2; j < sum; j += acc[i]) {
                if (!acc.canFind(j)) {
                    ok = false;
                    break;
                }
            }
            if (ok) return sum / acc[i];
        }
    }
    return 1;
}

void main() {
    readint;
    auto a = readints;
    writeln(calc(a));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
0