結果

問題 No.143 豆
ユーザー intercept6
提出日時 2020-08-13 15:16:47
言語 TypeScript
(5.7.2)
結果
AC  
実行時間 64 ms / 1,000 ms
コード長 603 bytes
コンパイル時間 7,554 ms
コンパイル使用メモリ 228,888 KB
実行使用メモリ 39,552 KB
最終ジャッジ日時 2024-12-31 16:17:56
合計ジャッジ時間 9,446 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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