結果

問題 No.143 豆
ユーザー 濱田孝治濱田孝治
提出日時 2020-08-13 19:40:20
言語 TypeScript
(5.4.3)
結果
AC  
実行時間 79 ms / 1,000 ms
コード長 818 bytes
コンパイル時間 9,019 ms
コンパイル使用メモリ 253,904 KB
実行使用メモリ 42,396 KB
最終ジャッジ日時 2023-09-30 17:54:37
合計ジャッジ時間 11,149 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
42,272 KB
testcase_01 AC 77 ms
42,264 KB
testcase_02 AC 77 ms
42,216 KB
testcase_03 AC 78 ms
42,144 KB
testcase_04 AC 76 ms
42,196 KB
testcase_05 AC 77 ms
42,280 KB
testcase_06 AC 76 ms
42,260 KB
testcase_07 AC 77 ms
42,396 KB
testcase_08 AC 76 ms
42,280 KB
testcase_09 AC 79 ms
42,116 KB
testcase_10 AC 77 ms
42,276 KB
testcase_11 AC 78 ms
42,124 KB
testcase_12 AC 79 ms
42,172 KB
testcase_13 AC 77 ms
42,236 KB
testcase_14 AC 77 ms
42,340 KB
testcase_15 AC 78 ms
42,252 KB
testcase_16 AC 79 ms
42,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function sum(array: number[]): number {
  let sum: number = 0;
  array.forEach(function (elm) {
    sum += elm;
  })
  return sum;
}

function Main(input: any) {
  // inputにはすべての入力の文字列が与えられるので必要に応じて input.split("\n") などで分割する。
  const data = input.split("\n");
  const first_line: string = data[0].split(" ");
  const K: number = Number(first_line[0]);
  const N: number = Number(first_line[1]);
  const F: number = Number(first_line[2]);

  const ageNumbers: number[] = data[1].split(" ").map(Number);
  const ageSum: number = sum(ageNumbers);
  const nokori: number = K * N - ageSum;

  if (nokori >= 0) {
    console.log(nokori)
  } else {
    console.log(-1);
  }
}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0