結果

問題 No.1594 Three Classes
ユーザー irumo8202
提出日時 2022-02-12 23:41:19
言語 TypeScript
(5.7.2)
結果
AC  
実行時間 1,442 ms / 2,000 ms
コード長 819 bytes
コンパイル時間 8,482 ms
コンパイル使用メモリ 228,992 KB
実行使用メモリ 165,808 KB
最終ジャッジ日時 2024-12-31 16:44:57
合計ジャッジ時間 31,749 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import * as fs from "fs"

type Input = (args: string) => void

const product = (pool: number[], repeat: number) => {
    let result: number[][] = new Array(new Array())
    for (let i = 0; i < repeat; i++) {
        let tmp: number[][] = new Array()
        result.forEach(x => { pool.forEach(y => tmp.push(x.concat(y))) })
        result = tmp
    }
    return result
};

const main: Input = args => {
    const input = args.trim().split("\n");
    const N = +input.shift()
    const E = input.shift().split(" ").map(x => +x)

    let ans = false

    product([0, 1, 2], N).forEach(x => {
        let team = Array(3).fill(0);
        E.forEach((e, i) => team[x[i]] += e)
        if (team.every(el => el === team[0])) ans = true
    })
    console.log(ans ? "Yes" : "No")
}

main(fs.readFileSync('/dev/stdin', 'utf8'))
0