結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
mlpj56d
|
| 提出日時 | 2017-06-23 13:27:32 |
| 言語 | JavaScript (node v23.5.0) |
| 結果 |
AC
|
| 実行時間 | 73 ms / 5,000 ms |
| コード長 | 618 bytes |
| コンパイル時間 | 37 ms |
| コンパイル使用メモリ | 6,692 KB |
| 実行使用メモリ | 43,136 KB |
| 最終ジャッジ日時 | 2024-10-13 00:13:23 |
| 合計ジャッジ時間 | 3,441 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
function Main(input) {
var line = input.split("\n");
var L = +line[0];
var N = +line[1];
var W = line[2].split(" ").map(Number);
rapt(L, N, W);
}
function rapt(L, N, W) {
var widthSum = 0;
var countBox = 0;
W.sort(function (a, b) {
if (a < b) return -1;
if (a > b) return 1;
return 0;
});
for (var i = 0; widthSum <= L; i++) {
widthSum += W[i];
countBox += 1;
}
if (widthSum == L) {
console.log(countBox);
} else {
console.log(countBox - 1);
}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
mlpj56d