結果

問題 No.1934 Four Fruits
コンテスト
ユーザー Fullmoon8507
提出日時 2023-10-29 23:41:12
言語 JavaScript
(node v26.7.0 + ACL)
コンパイル:
true
実行:
node _filename_ ONLINE_JUDGE
結果
AC  
実行時間 40 ms / 2,000 ms
+ 285µs
コード長 976 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3 ms
コンパイル使用メモリ 6,272 KB
実行使用メモリ 49,140 KB
最終ジャッジ日時 2026-09-04 06:00:21
合計ジャッジ時間 1,780 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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