結果
問題 | No.29 パワーアップ |
ユーザー |
![]() |
提出日時 | 2017-08-26 20:18:28 |
言語 | Ruby (3.1.1p18 ) |
結果 |
AC
|
実行時間 | 77 ms / 5,000 ms |
コード長 | 822 bytes |
コンパイル時間 | 33 ms |
使用メモリ | 14,064 KB |
最終ジャッジ日時 | 2022-12-11 22:52:48 |
合計ジャッジ時間 | 3,179 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge10 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 74 ms
13,936 KB |
testcase_01 | AC | 75 ms
13,980 KB |
testcase_02 | AC | 75 ms
13,824 KB |
testcase_03 | AC | 74 ms
13,840 KB |
testcase_04 | AC | 74 ms
13,720 KB |
testcase_05 | AC | 75 ms
13,840 KB |
testcase_06 | AC | 77 ms
13,720 KB |
testcase_07 | AC | 75 ms
13,856 KB |
testcase_08 | AC | 74 ms
14,012 KB |
testcase_09 | AC | 74 ms
13,808 KB |
testcase_10 | AC | 75 ms
13,956 KB |
testcase_11 | AC | 75 ms
14,064 KB |
testcase_12 | AC | 74 ms
13,816 KB |
testcase_13 | AC | 73 ms
13,804 KB |
testcase_14 | AC | 72 ms
13,808 KB |
testcase_15 | AC | 74 ms
13,720 KB |
testcase_16 | AC | 73 ms
13,712 KB |
testcase_17 | AC | 73 ms
13,892 KB |
testcase_18 | AC | 74 ms
13,796 KB |
testcase_19 | AC | 73 ms
13,900 KB |
testcase_20 | AC | 76 ms
13,896 KB |
testcase_21 | AC | 75 ms
13,720 KB |
コンパイルメッセージ
Syntax OK
ソースコード
input = [] while line = gets #入力のEOF(nil)に達するまで各行を読み込んでline変数に代入するwhile処理 line.chomp! input << line end battle_num = input[0].to_i #バトル回数 get_item = [] #手に入れたすべてのアイテムのリスト item_variety = [] #手に入れたアイテムの種類リスト powerup = 0 #パワーアップ回数 for i in 1..battle_num get_item << input[i].split(" ") item_variety << input[i].split(" ") end get_item.flatten! #多次元を1次元のリストに item_variety.flatten!.sort!.uniq! #配列をソートして重複を排除 #同種類パワーアップ item_variety.each{|j| powerup += get_item.count(j) / 2 if get_item.count(j) >= 2 } #4個パワーアップ powerup += (get_item.length - (powerup * 2)) / 4 puts powerup