結果

問題 No.806 木を道に
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-02-07 02:49:46
言語 Ruby
(3.2.2)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 162 bytes
コンパイル時間 40 ms
コンパイル使用メモリ 11,524 KB
実行使用メモリ 16,220 KB
最終ジャッジ日時 2023-09-18 11:50:39
合計ジャッジ時間 5,352 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,872 KB
testcase_01 AC 80 ms
16,008 KB
testcase_02 AC 82 ms
15,880 KB
testcase_03 AC 81 ms
15,872 KB
testcase_04 AC 79 ms
16,008 KB
testcase_05 AC 80 ms
16,016 KB
testcase_06 AC 81 ms
15,792 KB
testcase_07 AC 82 ms
16,136 KB
testcase_08 AC 77 ms
16,076 KB
testcase_09 AC 78 ms
16,012 KB
testcase_10 AC 111 ms
16,020 KB
testcase_11 AC 108 ms
16,020 KB
testcase_12 AC 205 ms
15,984 KB
testcase_13 AC 170 ms
16,028 KB
testcase_14 AC 198 ms
16,180 KB
testcase_15 AC 209 ms
16,032 KB
testcase_16 AC 126 ms
16,188 KB
testcase_17 AC 192 ms
16,132 KB
testcase_18 AC 92 ms
16,004 KB
testcase_19 AC 114 ms
15,988 KB
testcase_20 AC 191 ms
16,116 KB
testcase_21 AC 143 ms
15,964 KB
testcase_22 AC 235 ms
16,028 KB
testcase_23 AC 230 ms
15,900 KB
testcase_24 AC 156 ms
16,216 KB
testcase_25 AC 195 ms
15,964 KB
testcase_26 AC 123 ms
16,220 KB
testcase_27 AC 222 ms
15,960 KB
testcase_28 AC 83 ms
15,952 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

cs=Array.new(100001,0)
n=gets.to_i
(n-1).times{
	a,b=gets.split(" ").map{|e| e.to_i}
	cs[a]+=1
	cs[b]+=1
}
ans=0
1.upto(n){|i|
	ans+=cs[i]-2 if cs[i]>2
}
puts ans
0