結果
問題 |
No.143 豆
|
ユーザー |
![]() |
提出日時 | 2020-08-13 19:40:20 |
言語 | TypeScript (5.7.2) |
結果 |
AC
|
実行時間 | 66 ms / 1,000 ms |
コード長 | 818 bytes |
コンパイル時間 | 8,818 ms |
コンパイル使用メモリ | 228,680 KB |
実行使用メモリ | 39,424 KB |
最終ジャッジ日時 | 2024-12-31 16:18:42 |
合計ジャッジ時間 | 10,610 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
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"));