結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
42,580 KB
testcase_01 AC 83 ms
42,436 KB
testcase_02 AC 85 ms
42,464 KB
testcase_03 AC 85 ms
42,552 KB
testcase_04 AC 86 ms
42,440 KB
testcase_05 AC 90 ms
42,636 KB
testcase_06 AC 87 ms
42,608 KB
testcase_07 AC 86 ms
44,620 KB
testcase_08 AC 86 ms
44,516 KB
testcase_09 AC 87 ms
42,480 KB
testcase_10 AC 85 ms
42,624 KB
testcase_11 AC 85 ms
42,456 KB
testcase_12 AC 86 ms
42,608 KB
testcase_13 AC 86 ms
42,616 KB
testcase_14 AC 84 ms
42,468 KB
testcase_15 AC 86 ms
42,552 KB
testcase_16 AC 85 ms
42,664 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;

  // map関数とアロー関数でスッキリ書けるね
  secondLine.map((age) => {beans -= age});

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