Submission #3205163
Source Code Expand
# 入力の受け取り
input_line = readlines
input_line_first = input_line[0].split(" ")
input_line_second = input_line[1].split(" ")
# 受け取るパラメータ
children_num = input_line_first[0].to_i
candy_num = input_line_first[1].to_i
children_want_candy_num_array = input_line_second.map(&:to_i)
# 欲しいお菓子の数配列を昇順にソー1ト
children_want_candy_num_array.sort!
# 喜ぶ子供の人数を最大化
happy_children_count = 0
children_want_candy_num_array.each do |want_candy_num|
candy_num = candy_num - want_candy_num
if candy_num < 0
break
end
happy_children_count += 1
end
if candy_num > 0
happy_children_count -= 1
end
# 喜ぶ人数の最大値を出力
p happy_children_count
Submission Info
| Submission Time | |
|---|---|
| Task | A - Candy Distribution Again |
| User | sensuikan1973 |
| Language | Ruby (2.3.3) |
| Score | 200 |
| Code Size | 764 Byte |
| Status | AC |
| Exec Time | 8 ms |
| Memory | 1788 KiB |
Compile Error
./Main.rb:7: warning: assigned but unused variable - children_num
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
| All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 0_00.txt | AC | 7 ms | 1788 KiB |
| 0_01.txt | AC | 7 ms | 1788 KiB |
| 0_02.txt | AC | 7 ms | 1788 KiB |
| 0_03.txt | AC | 7 ms | 1788 KiB |
| 1_00.txt | AC | 7 ms | 1788 KiB |
| 1_01.txt | AC | 8 ms | 1788 KiB |
| 1_02.txt | AC | 7 ms | 1788 KiB |
| 1_03.txt | AC | 7 ms | 1788 KiB |
| 1_04.txt | AC | 7 ms | 1788 KiB |
| 1_05.txt | AC | 8 ms | 1788 KiB |
| 1_06.txt | AC | 7 ms | 1788 KiB |
| 1_07.txt | AC | 8 ms | 1788 KiB |