結果

問題 No.1594 Three Classes
ユーザー irumo8202irumo8202
提出日時 2022-02-12 23:41:19
言語 TypeScript
(5.4.3)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 819 bytes
コンパイル時間 4,540 ms
コンパイル使用メモリ 144,744 KB
最終ジャッジ日時 2024-04-28 00:48:24
合計ジャッジ時間 5,249 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.ts(1,21): error TS2307: Cannot find module 'fs' or its corresponding type declarations.

ソースコード

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