結果

問題 No.806 木を道に
ユーザー gemmarogemmaro
提出日時 2020-04-25 20:07:54
言語 Ruby
(3.3.0)
結果
AC  
実行時間 355 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 28,032 KB
最終ジャッジ日時 2024-04-25 08:01:59
合計ジャッジ時間 7,033 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
12,416 KB
testcase_01 AC 78 ms
12,160 KB
testcase_02 AC 83 ms
12,160 KB
testcase_03 AC 82 ms
12,160 KB
testcase_04 AC 79 ms
12,160 KB
testcase_05 AC 82 ms
12,160 KB
testcase_06 AC 76 ms
12,160 KB
testcase_07 AC 77 ms
12,160 KB
testcase_08 AC 78 ms
12,288 KB
testcase_09 AC 77 ms
12,160 KB
testcase_10 AC 142 ms
15,232 KB
testcase_11 AC 131 ms
14,976 KB
testcase_12 AC 297 ms
25,472 KB
testcase_13 AC 235 ms
21,120 KB
testcase_14 AC 304 ms
25,856 KB
testcase_15 AC 302 ms
25,728 KB
testcase_16 AC 161 ms
16,128 KB
testcase_17 AC 273 ms
25,088 KB
testcase_18 AC 101 ms
13,056 KB
testcase_19 AC 139 ms
15,360 KB
testcase_20 AC 275 ms
24,960 KB
testcase_21 AC 187 ms
18,944 KB
testcase_22 AC 344 ms
27,136 KB
testcase_23 AC 355 ms
27,136 KB
testcase_24 AC 217 ms
20,224 KB
testcase_25 AC 282 ms
24,832 KB
testcase_26 AC 155 ms
16,384 KB
testcase_27 AC 327 ms
28,032 KB
testcase_28 AC 90 ms
12,416 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

class Array # rubocop:todo Style/Documentation
  def solve # rubocop:todo Metrics/AbcSize
    a = each_with_object({}) do |item, result|
      result[item[0]] ||= []
      result[item[1]] ||= []
      result[item[0]] << item[1]
      result[item[1]] << item[0]
    end
    a.map { |_k, v| [v.size - 2, 0].max }.sum
  end
end

N = gets.to_i
A = (N - 1).times.map { gets.chomp.split.map(&:to_i) }

RESULT = A.solve

puts RESULT
0