結果

問題 No.143 豆
ユーザー sasaken555
提出日時 2016-12-23 21:16:01
言語 JavaScript
(node v23.5.0)
結果
AC  
実行時間 81 ms / 1,000 ms
コード長 581 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 6,692 KB
実行使用メモリ 42,416 KB
最終ジャッジ日時 2024-07-23 10:39:34
合計ジャッジ時間 2,188 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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