結果

問題 No.1594 Three Classes
ユーザー kokatsu
提出日時 2021-12-05 17:52:24
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 2,435 ms
コンパイル使用メモリ 210,140 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 13:34:39
合計ジャッジ時間 4,127 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

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

    auto E = readln.chomp.split.to!(int[]);

    int lim = 3 ^^ N;
    bool isOK;
    foreach (i; 0 .. lim) {
        int num = i;
        auto P = new int[](3);
        foreach (e; E) {
            P[num%3] += e;
            num /= 3;
        }

        isOK |= (P[0] == P[1] && P[1] == P[2]);
    }

    writeln(isOK ? "Yes" : "No");
}
0