結果

問題 No.19 ステージの選択
ユーザー gigurururugigurururu
提出日時 2015-01-01 22:49:15
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 407 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 11,276 KB
実行使用メモリ 15,328 KB
最終ジャッジ日時 2023-09-03 20:20:56
合計ジャッジ時間 3,763 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
15,072 KB
testcase_01 AC 68 ms
15,144 KB
testcase_02 AC 69 ms
15,148 KB
testcase_03 AC 68 ms
15,240 KB
testcase_04 AC 71 ms
15,108 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 70 ms
15,112 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 68 ms
15,140 KB
testcase_11 AC 70 ms
15,276 KB
testcase_12 AC 70 ms
15,152 KB
testcase_13 AC 71 ms
15,020 KB
testcase_14 WA -
testcase_15 AC 69 ms
15,136 KB
testcase_16 AC 70 ms
15,092 KB
testcase_17 AC 73 ms
15,248 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 71 ms
15,328 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require'tsort'
class Array
  include TSort
  alias tsort_each_node each_index
  def tsort_each_child(node, &block)
    block.call self[node]
  end
end

r=1..n=gets.to_i
s=[]
l=r.map{|i|a,b=gets.split;s[i-1]=b.to_i-1;a.to_f}

gone=[false]*n
sum=0
s.each_strongly_connected_component{|a|
  c=a.min_by{|i|l[i]}
  while c&&!gone[c]
    sum+=gone[s[c]]?l[c]/2:l[c]
    gone[c]=true
    c=s.index(c)
  end
}
p sum
0