結果

問題 No.119 旅行のツアーの問題
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-02-18 06:35:25
言語 Ruby
(3.3.0)
結果
AC  
実行時間 186 ms / 5,000 ms
コード長 392 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 11,472 KB
実行使用メモリ 15,780 KB
最終ジャッジ日時 2023-08-23 09:15:21
合計ジャッジ時間 3,681 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
15,380 KB
testcase_01 AC 159 ms
15,688 KB
testcase_02 AC 81 ms
15,284 KB
testcase_03 AC 81 ms
15,128 KB
testcase_04 AC 81 ms
15,096 KB
testcase_05 AC 116 ms
15,312 KB
testcase_06 AC 177 ms
15,780 KB
testcase_07 AC 81 ms
15,140 KB
testcase_08 AC 83 ms
15,312 KB
testcase_09 AC 81 ms
15,324 KB
testcase_10 AC 80 ms
15,092 KB
testcase_11 AC 81 ms
15,092 KB
testcase_12 AC 82 ms
15,256 KB
testcase_13 AC 83 ms
15,164 KB
testcase_14 AC 138 ms
15,684 KB
testcase_15 AC 95 ms
15,156 KB
testcase_16 AC 140 ms
15,628 KB
testcase_17 AC 82 ms
15,304 KB
testcase_18 AC 88 ms
15,104 KB
testcase_19 AC 94 ms
15,148 KB
testcase_20 AC 140 ms
15,468 KB
testcase_21 AC 168 ms
15,668 KB
testcase_22 AC 186 ms
15,712 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

z=9999
n=gets.to_i
g=(1..l=n*5).map{[0]*l}
a=0
(1..n).map{|u|b,c=gets.split;a+=g[1][v=2+u]=b.to_i;a+=g[w=n+v][2]=c.to_i;g[v][w]=z}
gets.to_i.times{d,e=gets.split;g[3+d.to_i][3+n+e.to_i]=z}
(q=[1]
p=[0]*l
(u=q.shift;l.times{|v|(p[v]=u;q<<v)if p[v]<1&&g[u][v]>0})while q!=[]
break if p[v=w=2]<1
m=z
(m=[m,g[u=p[v]][v]].min;v=u)while v>1
a-=m
(g[u=p[w]][w]-=m;g[w][w=u]+=m)while w>1)until !n
p a
0