結果

問題 No.99 ジャンピング駒
ユーザー mizzsigmizzsig
提出日時 2017-05-13 22:52:22
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 167 ms / 5,000 ms
コード長 760 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 55,644 KB
最終ジャッジ日時 2024-04-21 01:42:36
合計ジャッジ時間 1,659 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 162 ms
55,640 KB
testcase_01 AC 167 ms
55,640 KB
testcase_02 AC 160 ms
55,512 KB
testcase_03 AC 159 ms
55,644 KB
testcase_04 AC 159 ms
55,512 KB
testcase_05 AC 160 ms
55,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let inputs = ``;

process.stdin.on('data', function (chunk) {
    inputs += chunk;
});

process.stdin.on('end', function () {
    let input = inputs.split("\n");
    let input2 = input[1].split(" ");
    
    input[0] = parseInt(input[0]);
    for(let i = 0; i < input[0]; i++){
        input2[i] = parseInt(input2[i]);
    }

    for(let value of input2){
        value = parseInt(value);
    }
    
    let even = 0;
    let odd = 0;
    
    for(let i = 0; i < input[0]; i++){
        if(input2[i] % 2 == 0){
            even++;
        }else{
            odd++;
        }
    }
    
    let ans = () => {
        if(even > odd){
            return even - odd;
        }else{
            return odd - even;
        }
    };
    
    console.log(ans());
});
0