結果
| 問題 | 
                            No.5 数字のブロック
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-04-27 08:02:14 | 
| 言語 | JavaScript  (node v23.5.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 555 bytes | 
| コンパイル時間 | 94 ms | 
| コンパイル使用メモリ | 6,692 KB | 
| 実行使用メモリ | 43,520 KB | 
| 最終ジャッジ日時 | 2024-10-13 01:07:05 | 
| 合計ジャッジ時間 | 3,191 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 24 WA * 10 | 
ソースコード
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;
	}
	main() {
		const arr = this.W.sort((a, b)=>{return a-b;});
		for(let i=0;this.N>i; i++) {
			if(i === (this.N-1)) {
				this.dest(i);
				break;
			}else if(this.sum <= this.L) {
				this.sum += arr[i];
			}else {
				this.dest(i-1);
				break;
			}
		}
	}
	dest(ans) {
		console.log(ans);
	}
}
new Answer(require("fs").readFileSync("/dev/stdin", "utf8")).main();