結果

問題 No.143 豆
ユーザー ontama_12ontama_12
提出日時 2016-09-23 15:17:49
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 84 ms / 1,000 ms
コード長 761 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 5,220 KB
実行使用メモリ 42,588 KB
最終ジャッジ日時 2023-09-30 16:51:31
合計ジャッジ時間 2,858 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
42,316 KB
testcase_01 AC 81 ms
42,452 KB
testcase_02 AC 82 ms
42,216 KB
testcase_03 AC 81 ms
42,208 KB
testcase_04 AC 82 ms
42,212 KB
testcase_05 AC 81 ms
42,588 KB
testcase_06 AC 82 ms
42,464 KB
testcase_07 AC 82 ms
42,304 KB
testcase_08 AC 82 ms
42,444 KB
testcase_09 AC 83 ms
42,324 KB
testcase_10 AC 84 ms
42,212 KB
testcase_11 AC 82 ms
42,360 KB
testcase_12 AC 82 ms
42,332 KB
testcase_13 AC 82 ms
42,468 KB
testcase_14 AC 82 ms
42,380 KB
testcase_15 AC 83 ms
42,320 KB
testcase_16 AC 82 ms
42,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

  ///////// 	No.143 豆
    //入力文字読み取り
    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    process.stdin.on('data', function (chunk) {

    //すべて受け取り改行で区切って格納
    var input = chunk.split("\n");

    //豆、袋、家族の人数
    var bean = input[0].split(" ").map(Number)
    //家族の年齢
    var age = input[1].split(" ").map(Number)

    //豆の合計
    var beansum = bean[0] * bean[1];
    
    //家族の年齢の合計
    var agesum =0
    for (var i = 0; i < bean[2]; i++) {
       agesum +=  age[i]
    }

    //豆がいくつ余るか計算
    var result = beansum - agesum

    if (result < 0) {
        console.log(-1)
    } else {
        console.log(result)
    }
})
0