結果

問題 No.143 豆
ユーザー f Oxf Ox
提出日時 2021-04-14 22:08:31
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 78 ms / 1,000 ms
コード長 685 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 42,372 KB
最終ジャッジ日時 2023-09-13 11:37:26
合計ジャッジ時間 3,120 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
42,284 KB
testcase_01 AC 74 ms
42,372 KB
testcase_02 AC 75 ms
42,336 KB
testcase_03 AC 74 ms
42,176 KB
testcase_04 AC 74 ms
42,148 KB
testcase_05 AC 74 ms
42,132 KB
testcase_06 AC 75 ms
42,100 KB
testcase_07 AC 75 ms
42,188 KB
testcase_08 AC 77 ms
42,128 KB
testcase_09 AC 75 ms
42,264 KB
testcase_10 AC 75 ms
42,312 KB
testcase_11 AC 75 ms
42,336 KB
testcase_12 AC 74 ms
42,124 KB
testcase_13 AC 75 ms
42,300 KB
testcase_14 AC 74 ms
42,204 KB
testcase_15 AC 75 ms
42,104 KB
testcase_16 AC 74 ms
42,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main(input) {
  const data = input.split("\n");

  const dataBase = data[0].split(" "); // 1行目の配列
  const K = Number(dataBase[0]); // 1袋の粒数
  const N = Number(dataBase[1]); // 袋の数
  const F = Number(dataBase[2]); // 家族の人数

  const dataAge = data[1].split(" "); // 2行目の配列
  const age = dataAge.map(Number); // 配列を文字列から数値に変換する。

  const amountBeen = K*N; // ある粒数
  const needBeen = age.reduce((a,b)=>a+b); // 必要な粒数

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


}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0