結果
問題 | No.17 2つの地点に泊まりたい |
ユーザー | リチウム |
提出日時 | 2014-11-17 22:56:14 |
言語 | Java21 (openjdk 21) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,065 bytes |
コンパイル時間 | 2,492 ms |
コンパイル使用メモリ | 74,164 KB |
実行使用メモリ | 59,516 KB |
最終ジャッジ日時 | 2023-08-30 20:28:44 |
合計ジャッジ時間 | 7,904 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 117 ms
55,760 KB |
testcase_01 | AC | 118 ms
56,080 KB |
testcase_02 | AC | 122 ms
56,184 KB |
testcase_03 | AC | 157 ms
56,024 KB |
testcase_04 | AC | 170 ms
56,388 KB |
testcase_05 | AC | 198 ms
59,292 KB |
testcase_06 | AC | 185 ms
58,580 KB |
testcase_07 | AC | 188 ms
58,564 KB |
testcase_08 | AC | 202 ms
59,516 KB |
testcase_09 | AC | 208 ms
59,236 KB |
testcase_10 | AC | 191 ms
56,464 KB |
testcase_11 | AC | 197 ms
59,060 KB |
testcase_12 | AC | 120 ms
56,412 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 194 ms
58,404 KB |
testcase_24 | AC | 192 ms
58,732 KB |
testcase_25 | AC | 131 ms
56,204 KB |
testcase_26 | AC | 199 ms
58,620 KB |
ソースコード
import java.util.*; public class Main { static Scanner sc; static int n,m; static void Warshall_Floyd_Algorithm(int n, int N[][]) { for (int i = 0; i < n; i++) { Arrays.fill(N[i], Integer.MAX_VALUE / 2); N[i][i] = 0; } for(int i=0;i<m;i++){ int x=sc.nextInt(); int y=sc.nextInt(); int c=sc.nextInt(); N[x][y]=N[y][x]=c; } //初期条件をここに挿入 for (int k = 0; k < n; ++k) { for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { N[i][j] = Math.min(N[i][j], N[i][k] + N[k][j]); } } } } public static void main(String[] args) { sc=new Scanner(System.in); n=sc.nextInt(); int s[]=new int[n]; for(int i=0;i<n;i++){ s[i]=sc.nextInt(); } int map[][]=new int[n][n]; m=sc.nextInt(); Warshall_Floyd_Algorithm(n,map); int ans=Integer.MAX_VALUE; for(int i=1;i<n-1;i++){ for(int j=1;j<n-1;j++){ if(i==j)continue; ans=Math.min(ans,map[0][i]+s[i]+map[i][j]+s[j]+map[j][n-1]); } } System.out.println(ans); }}