結果

問題 No.29 パワーアップ
ユーザー harhogefooharhogefoo
提出日時 2016-10-05 10:51:51
言語 Ruby
(3.2.2)
結果
AC  
実行時間 82 ms / 5,000 ms
コード長 421 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 11,088 KB
実行使用メモリ 15,296 KB
最終ジャッジ日時 2023-08-13 23:11:58
合計ジャッジ時間 2,965 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,144 KB
testcase_01 AC 81 ms
15,124 KB
testcase_02 AC 82 ms
15,192 KB
testcase_03 AC 82 ms
15,180 KB
testcase_04 AC 81 ms
15,264 KB
testcase_05 AC 79 ms
15,064 KB
testcase_06 AC 80 ms
15,120 KB
testcase_07 AC 81 ms
15,016 KB
testcase_08 AC 81 ms
15,228 KB
testcase_09 AC 81 ms
15,280 KB
testcase_10 AC 80 ms
15,064 KB
testcase_11 AC 82 ms
15,284 KB
testcase_12 AC 81 ms
15,296 KB
testcase_13 AC 82 ms
15,012 KB
testcase_14 AC 81 ms
15,036 KB
testcase_15 AC 81 ms
15,236 KB
testcase_16 AC 81 ms
15,244 KB
testcase_17 AC 81 ms
15,284 KB
testcase_18 AC 82 ms
15,092 KB
testcase_19 AC 80 ms
15,256 KB
testcase_20 AC 81 ms
15,032 KB
testcase_21 AC 81 ms
15,272 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

numbers = (1..10).to_a
init_ary = Array.new(numbers.length, 0)
ary = [numbers, init_ary].transpose
h = Hash[*ary.flatten]

n = gets.to_i
n.times do
  a = gets.chomp.split(" ").map(&:to_i)
  a.each do |i|
    h[i] += 1
  end
end

# 2で割った値をカウント
count = 0
h.each do |k, v|
  count += v / 2
  h[k] = v % 2
end

# 要素が1のものを選択
h = h.select { |k, v| v == 1 }
count += h.length / 4
puts count
0