結果
問題 | No.5 数字のブロック |
ユーザー | はとばねぇ |
提出日時 | 2019-04-27 08:20:05 |
言語 | JavaScript (node v23.5.0) |
結果 |
AC
|
実行時間 | 75 ms / 5,000 ms |
コード長 | 589 bytes |
コンパイル時間 | 110 ms |
コンパイル使用メモリ | 6,820 KB |
実行使用メモリ | 43,264 KB |
最終ジャッジ日時 | 2024-10-13 01:07:22 |
合計ジャッジ時間 | 3,323 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
class Answer { constructor(input) { const data = input.split('\n'); this.L = Number(data[0]); this.N = Number(data[1]); this.W = data[2].split(' ').map(Number); this.sum = 0; this.block = 0; } main() { const arr = this.W.sort((a, b)=>{return a-b;}); for(let i=0;this.N>i; i++) { this.sum += arr[i]; if(this.sum <= this.L) this.block++; if(this.sum >= this.L || i === this.N-1) { this.dest(this.block); break; } } } dest(ans) { console.log(ans); } } new Answer(require("fs").readFileSync("/dev/stdin", "utf8")).main();