結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
15,388 KB
testcase_01 AC 158 ms
15,708 KB
testcase_02 AC 79 ms
15,132 KB
testcase_03 AC 80 ms
15,148 KB
testcase_04 AC 79 ms
15,024 KB
testcase_05 AC 113 ms
15,580 KB
testcase_06 AC 174 ms
15,620 KB
testcase_07 AC 81 ms
15,328 KB
testcase_08 AC 83 ms
15,180 KB
testcase_09 AC 81 ms
15,092 KB
testcase_10 AC 80 ms
15,052 KB
testcase_11 AC 78 ms
15,352 KB
testcase_12 AC 81 ms
15,284 KB
testcase_13 AC 83 ms
15,300 KB
testcase_14 AC 136 ms
15,836 KB
testcase_15 AC 92 ms
15,240 KB
testcase_16 AC 138 ms
15,672 KB
testcase_17 AC 79 ms
15,212 KB
testcase_18 AC 86 ms
15,284 KB
testcase_19 AC 90 ms
15,208 KB
testcase_20 AC 140 ms
15,608 KB
testcase_21 AC 169 ms
15,788 KB
testcase_22 AC 184 ms
15,660 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

z=9999
n=gets.to_i
l=n*5
g=(1..l).map{[0]*l}
a=0
(1..n).map{|u|b,c=gets.split;a+=g[1][2+u]=b.to_i;a+=g[r=2+n+u][2]=c.to_i;g[2+u][r]=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.any?
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][u]+=m;w=u)while w>1
)while !!n
p a
0