結果

問題 No.143 豆
ユーザー sasaken555sasaken555
提出日時 2016-12-23 21:00:01
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 87 ms / 1,000 ms
コード長 543 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 44,476 KB
最終ジャッジ日時 2023-09-30 16:55:01
合計ジャッジ時間 2,945 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
42,580 KB
testcase_01 AC 83 ms
44,476 KB
testcase_02 AC 84 ms
42,660 KB
testcase_03 AC 83 ms
42,440 KB
testcase_04 AC 83 ms
42,576 KB
testcase_05 AC 84 ms
42,628 KB
testcase_06 AC 85 ms
42,708 KB
testcase_07 AC 84 ms
42,652 KB
testcase_08 AC 87 ms
42,676 KB
testcase_09 AC 85 ms
42,648 KB
testcase_10 AC 85 ms
42,580 KB
testcase_11 AC 84 ms
42,580 KB
testcase_12 AC 84 ms
42,580 KB
testcase_13 AC 85 ms
42,628 KB
testcase_14 AC 84 ms
42,520 KB
testcase_15 AC 84 ms
42,628 KB
testcase_16 AC 85 ms
42,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let lines = [];
let reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', function(line) {
  lines.push(line);
});

reader.on('close', function() {
  let firstLine = lines[0].split(' ');
  let secondLine = lines[1].split(' ');

  const K = firstLine[0];
  const N = firstLine[1];
  const F = firstLine[2];
  let beans = K * N;

  for(let i = 0; i < F; i++) {
    beans -= secondLine[i];
  }

  if (beans >= 0) {
    console.log(beans);
  }
  else {
    console.log(-1);
  }
});
0