結果

問題 No.17 2つの地点に泊まりたい
ユーザー %20%20
提出日時 2017-07-18 00:45:14
言語 Perl
(5.38.2)
結果
AC  
実行時間 58 ms / 5,000 ms
コード長 476 bytes
コンパイル時間 66 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2024-04-23 02:20:20
合計ジャッジ時間 1,441 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,632 KB
testcase_01 AC 3 ms
5,632 KB
testcase_02 AC 5 ms
5,504 KB
testcase_03 AC 58 ms
5,888 KB
testcase_04 AC 9 ms
5,632 KB
testcase_05 AC 38 ms
5,888 KB
testcase_06 AC 23 ms
5,888 KB
testcase_07 AC 17 ms
5,760 KB
testcase_08 AC 55 ms
6,144 KB
testcase_09 AC 57 ms
6,016 KB
testcase_10 AC 46 ms
5,760 KB
testcase_11 AC 55 ms
5,888 KB
testcase_12 AC 3 ms
5,504 KB
testcase_13 AC 3 ms
5,632 KB
testcase_14 AC 3 ms
5,504 KB
testcase_15 AC 2 ms
5,632 KB
testcase_16 AC 3 ms
5,632 KB
testcase_17 AC 9 ms
5,504 KB
testcase_18 AC 47 ms
5,632 KB
testcase_19 AC 41 ms
5,760 KB
testcase_20 AC 7 ms
5,504 KB
testcase_21 AC 4 ms
5,504 KB
testcase_22 AC 49 ms
5,888 KB
testcase_23 AC 32 ms
5,760 KB
testcase_24 AC 44 ms
5,888 KB
testcase_25 AC 4 ms
5,632 KB
testcase_26 AC 50 ms
5,888 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Unquoted string "inf" may clash with future reserved word at Main.pl line 6.
Unquoted string "inf" may clash with future reserved word at Main.pl line 22.
Main.pl syntax OK

ソースコード

diff #

sub min{$_[$_[1]<$_[0]]}
$N=<>;
$S[$_]=<>for 0..$N-1;
for$i(0..$N-1){
	for$j(0..$N-1){
		$w[$i][$j]=inf;
	}
	$w[$i][$i]=0;
}
<>;
/ .* /,$w[$`][$&]=$w[$&][$`]=$' for<>;
for$m(0..$N-1){
	for$i(0..$N-1){
		for$j(0..$N-1){
			$w[$i][$j]=min(
				$w[$i][$j],
				$w[$i][$m]+$w[$m][$j]
			)
		}
	}
}
$z=inf;
for$x(1..$N-3){
	for$y($x+1..$N-2){
		$z=min(
			$z,
			$S[$x]+$S[$y]+min(
				$w[0][$x]+$w[$x][$y]+$w[$y][$N-1],
				$w[0][$y]+$w[$y][$x]+$w[$x][$N-1]
			)
		)
	}
}
print$z
0