結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
sjgq5302
|
| 提出日時 | 2017-07-19 21:42:51 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 588 bytes |
| コンパイル時間 | 724 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-10-08 14:33:21 |
| 合計ジャッジ時間 | 4,605 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 WA * 7 |
コンパイルメッセージ
Syntax OK
ソースコード
input = []
while line = gets #入力のEOF(nil)に達するまで各行を読み込んでline変数に代入するwhile処理
line.chomp!
input << line
end
box_width = input[0].to_i #箱の幅
block_num = input[1].to_i #ブロックの個数
block = input[2].split(" ").map(&:to_i) #それぞれのブロックの個数
block.sort!
sum = 0
cnt = 0
i = 0
while sum <= box_width and (i + 1) <= block_num do
sum += block[i]
cnt += 1
i += 1
end
if sum == box_width then #ブロックが箱にピッタリ収まる時
puts cnt
else
puts cnt - 1
end
sjgq5302