結果

問題 No.143 豆
ユーザー intercept6intercept6
提出日時 2020-08-13 15:16:47
言語 TypeScript
(5.4.3)
結果
AC  
実行時間 79 ms / 1,000 ms
コード長 603 bytes
コンパイル時間 9,584 ms
コンパイル使用メモリ 251,412 KB
実行使用メモリ 42,136 KB
最終ジャッジ日時 2023-09-30 17:53:54
合計ジャッジ時間 11,040 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
42,120 KB
testcase_01 AC 78 ms
42,004 KB
testcase_02 AC 79 ms
41,948 KB
testcase_03 AC 78 ms
42,136 KB
testcase_04 AC 78 ms
42,068 KB
testcase_05 AC 78 ms
42,120 KB
testcase_06 AC 79 ms
42,112 KB
testcase_07 AC 79 ms
41,928 KB
testcase_08 AC 79 ms
41,884 KB
testcase_09 AC 78 ms
42,068 KB
testcase_10 AC 79 ms
41,952 KB
testcase_11 AC 78 ms
42,124 KB
testcase_12 AC 78 ms
41,996 KB
testcase_13 AC 79 ms
41,992 KB
testcase_14 AC 78 ms
42,044 KB
testcase_15 AC 79 ms
42,036 KB
testcase_16 AC 78 ms
42,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import { readFileSync } from 'fs';

function Main(input: string) {
  const data = input.split('\n');

  const firstLine = data[0].split(' ').map(Number);
  const beans = firstLine[0] * firstLine[1];
  // const families = parseInt(firstLine[2]);

  const secondLine = data[1].split(' ').map(Number);
  const reducer = (accumulator: number, currentValue: number) => {
    return accumulator + currentValue;
  };
  const ages = secondLine.reduce(reducer);

  const res = beans - ages;

  if (res < 0) {
    console.log(-1);
  } else {
    console.log(res);
  }
}

Main(readFileSync('/dev/stdin', 'utf8'));
0