結果

問題 No.119 旅行のツアーの問題
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-02-21 00:19:34
言語 Ruby
(3.2.2)
結果
AC  
実行時間 131 ms / 5,000 ms
コード長 389 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 11,444 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2023-08-23 09:15:32
合計ジャッジ時間 3,471 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
15,100 KB
testcase_01 AC 121 ms
15,248 KB
testcase_02 AC 82 ms
15,176 KB
testcase_03 AC 83 ms
15,076 KB
testcase_04 AC 87 ms
15,028 KB
testcase_05 AC 105 ms
15,264 KB
testcase_06 AC 131 ms
15,028 KB
testcase_07 AC 82 ms
15,092 KB
testcase_08 AC 82 ms
15,256 KB
testcase_09 AC 85 ms
15,024 KB
testcase_10 AC 82 ms
15,264 KB
testcase_11 AC 82 ms
15,096 KB
testcase_12 AC 84 ms
15,144 KB
testcase_13 AC 86 ms
15,256 KB
testcase_14 AC 110 ms
15,360 KB
testcase_15 AC 96 ms
15,024 KB
testcase_16 AC 111 ms
15,104 KB
testcase_17 AC 86 ms
15,220 KB
testcase_18 AC 90 ms
15,088 KB
testcase_19 AC 94 ms
15,228 KB
testcase_20 AC 117 ms
15,152 KB
testcase_21 AC 131 ms
15,096 KB
testcase_22 AC 130 ms
15,208 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

z=1e9
n=gets.to_i
g=(1..l=99).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