結果

問題 No.1934 Four Fruits
ユーザー Fullmoon8507Fullmoon8507
提出日時 2022-09-24 14:36:22
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,275 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 5,380 KB
実行使用メモリ 42,224 KB
最終ジャッジ日時 2023-08-23 21:23:56
合計ジャッジ時間 2,928 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
42,120 KB
testcase_01 AC 75 ms
42,160 KB
testcase_02 AC 76 ms
42,224 KB
testcase_03 AC 74 ms
42,160 KB
testcase_04 AC 74 ms
42,152 KB
testcase_05 AC 78 ms
42,204 KB
testcase_06 AC 76 ms
42,124 KB
testcase_07 AC 75 ms
42,164 KB
testcase_08 AC 76 ms
42,128 KB
testcase_09 AC 79 ms
42,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main(input) {
    var data = input.split("\n");
    var first_line = data[0].split(" ");
    var second_line = data[1];

    var a = first_line[0];
    var b = first_line[1];
    var c = first_line[2];

    if (a === b && b === c) {
        console.log(a);
        return;
    }

    var count0 = 0;
    var count1 = 0;
    var count2 = 0;
    var count3 = 0;
    for (x of first_line) {
        if (x === '0') {
            count0 += 1;
        } else if (x === '1') {
            count1 += 1;
        } else if (x === '2') {
            count2 += 1;
        } else if (x === '3') {
            count3 += 1
        }
    }

    if (count0 === 2 || count1 === 2 || count2 ===2 || count3 ===2) {
        if (count0 === 1){
            console.log(0);
        } else if (count1 ===1) {
            console.log(1);
        } else if (count2 ===1) {
            console.log(2);
        } else {
            console.log(3);
        }
    } else {
        if (count0 === 0){
            console.log(0);
        } else if (count1 ===0) {
            console.log(1);
        } else if (count2 ===0) {
            console.log(2);
        } else {
            console.log(3);
        }
    }
}

// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8")); 
0