結果

問題 No.143 豆
ユーザー mondomondo
提出日時 2019-08-14 00:08:33
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 82 ms / 1,000 ms
コード長 557 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 43,892 KB
最終ジャッジ日時 2023-09-30 17:36:57
合計ジャッジ時間 2,161 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
41,972 KB
testcase_01 AC 82 ms
41,736 KB
testcase_02 AC 80 ms
41,904 KB
testcase_03 AC 77 ms
41,792 KB
testcase_04 AC 78 ms
41,736 KB
testcase_05 AC 77 ms
41,736 KB
testcase_06 AC 77 ms
41,752 KB
testcase_07 AC 77 ms
41,828 KB
testcase_08 AC 77 ms
41,764 KB
testcase_09 AC 78 ms
41,748 KB
testcase_10 AC 76 ms
41,936 KB
testcase_11 AC 76 ms
41,832 KB
testcase_12 AC 77 ms
41,744 KB
testcase_13 AC 77 ms
41,956 KB
testcase_14 AC 78 ms
41,832 KB
testcase_15 AC 77 ms
41,856 KB
testcase_16 AC 77 ms
43,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let main = (standardInput) => {
    var line = standardInput.trim().split("\n");
    var beansline  = line[0].trim().split(" ").map(Number);
    var membersline = line[1].trim().split(" ").map(Number);
    var beanssum = beansline[0] * beansline[1];
    var sum = membersline.reduce(function (accumulator, currentValue) {
    return accumulator + currentValue;
    }, 0);
    var ans = beanssum - sum;
    if (ans >= 0) {
        console.log(ans);    
    } else {
        console.log("-1");
    }
};
main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));
0