結果

問題 No.1934 Four Fruits
ユーザー Fullmoon8507Fullmoon8507
提出日時 2023-10-29 23:41:12
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 976 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 5,152 KB
実行使用メモリ 61,340 KB
最終ジャッジ日時 2023-10-29 23:41:17
合計ジャッジ時間 5,374 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
37,140 KB
testcase_01 AC 68 ms
37,224 KB
testcase_02 AC 67 ms
37,224 KB
testcase_03 AC 67 ms
37,224 KB
testcase_04 AC 67 ms
37,224 KB
testcase_05 AC 67 ms
37,224 KB
testcase_06 AC 67 ms
37,224 KB
testcase_07 AC 67 ms
37,224 KB
testcase_08 AC 67 ms
37,224 KB
testcase_09 AC 67 ms
61,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

var lines = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

var fruitsMap = new Map();
fruitsMap.set("0", 0);
fruitsMap.set("1", 0);
fruitsMap.set("2", 0);
fruitsMap.set("3", 0);

for(fruit of lines[0].split(" ")){
    var count = fruitsMap.get(fruit)
    fruitsMap.set(fruit, ++count);
}

var valuesList = Array.from(fruitsMap.values());
var maxNum = Math.max(...valuesList);

// 4 つのフルーツはすべて同じ種類である
if(maxNum === 3) {
    for([key, value] of fruitsMap){
        if(value === 3){
            console.log(key);
            break;
        }
    }
}

// 4 つのフルーツの種類はすべて異なる
else if(maxNum === 1){
    for([key, value] of fruitsMap){
        if(value === 0){
            console.log(key);
        }
    }
}

// 4 つのフルーツは 2 種類のフルーツ 2 つずつからなる
else {
    for([key, value] of fruitsMap){
        if(value === 1){
            console.log(key);
        }
    }
}
0