結果

問題 No.19 ステージの選択
ユーザー letrangerjpletrangerjp
提出日時 2017-06-03 14:17:39
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 470 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 11,284 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2023-08-24 23:31:50
合計ジャッジ時間 3,295 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,252 KB
testcase_01 AC 81 ms
15,276 KB
testcase_02 AC 80 ms
15,200 KB
testcase_03 AC 80 ms
15,268 KB
testcase_04 AC 83 ms
15,216 KB
testcase_05 AC 82 ms
15,248 KB
testcase_06 AC 82 ms
15,132 KB
testcase_07 AC 83 ms
15,264 KB
testcase_08 AC 81 ms
15,164 KB
testcase_09 AC 84 ms
15,264 KB
testcase_10 AC 81 ms
15,148 KB
testcase_11 AC 81 ms
15,060 KB
testcase_12 AC 80 ms
15,060 KB
testcase_13 AC 81 ms
15,200 KB
testcase_14 AC 82 ms
15,252 KB
testcase_15 AC 82 ms
15,112 KB
testcase_16 AC 81 ms
15,116 KB
testcase_17 AC 80 ms
15,236 KB
testcase_18 AC 81 ms
15,248 KB
testcase_19 AC 82 ms
15,160 KB
testcase_20 AC 82 ms
15,264 KB
testcase_21 AC 82 ms
15,360 KB
testcase_22 AC 81 ms
15,252 KB
testcase_23 AC 82 ms
15,232 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:23: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

#!ruby -rtsort

class Array
  include TSort
  alias tsort_each_node each_index
  def tsort_each_child(node)
    yield self[node]
  end
end

N=gets.to_i
L=[]
S=[]
N.times.map{
  a, b = gets.split.take(2).map(&:to_i)
  L << a
  S << b-1
}

used = []
p S.strongly_connected_components.map{|a|
  t = a.min_by{|i|L[i]}
  n = a.map{|i|
    if i != t || used[S[i]]
      L[i]/2.0
    else
      L[i]
    end
  }.sum.tap{
    a.each{|i|
      used[i] = true
    }
  }
}.sum*1.0
0