結果
問題 | No.17 2つの地点に泊まりたい |
ユーザー | 37zigen |
提出日時 | 2016-03-07 21:58:30 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,030 bytes |
コンパイル時間 | 2,391 ms |
コンパイル使用メモリ | 77,224 KB |
実行使用メモリ | 61,268 KB |
最終ジャッジ日時 | 2023-10-24 20:16:02 |
合計ジャッジ時間 | 7,500 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 124 ms
57,588 KB |
testcase_01 | AC | 123 ms
57,528 KB |
testcase_02 | AC | 119 ms
56,168 KB |
testcase_03 | AC | 145 ms
57,936 KB |
testcase_04 | AC | 171 ms
57,904 KB |
testcase_05 | WA | - |
testcase_06 | AC | 187 ms
59,728 KB |
testcase_07 | AC | 189 ms
60,016 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 123 ms
57,316 KB |
testcase_13 | AC | 111 ms
56,248 KB |
testcase_14 | AC | 111 ms
56,152 KB |
testcase_15 | AC | 113 ms
56,196 KB |
testcase_16 | AC | 122 ms
57,636 KB |
testcase_17 | AC | 130 ms
55,328 KB |
testcase_18 | AC | 152 ms
57,804 KB |
testcase_19 | AC | 140 ms
57,520 KB |
testcase_20 | WA | - |
testcase_21 | AC | 112 ms
56,280 KB |
testcase_22 | AC | 145 ms
57,600 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 132 ms
57,792 KB |
testcase_26 | WA | - |
ソースコード
import java.io.PrintWriter; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { PrintWriter pw=new PrintWriter(System.out); Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] stcst=new int[n]; for(int i=0;i<n;i++){ stcst[i]=sc.nextInt(); } int[][] mvcst=new int[n][n]; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ mvcst[i][j]=1000000; } } int m=sc.nextInt(); for(int i=0;i<m;i++){ int from=sc.nextInt(); int to=sc.nextInt(); int cst=sc.nextInt(); mvcst[from][to]=cst; mvcst[to][from]=cst; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ for(int k=0;k<n;k++){ mvcst[i][j]=Math.min(mvcst[i][j], mvcst[i][k]+mvcst[k][j]); } } } 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; int tmp=mvcst[i][0]+mvcst[i][j]+mvcst[n-1][j]+stcst[i]+stcst[j]; ans=Math.min(tmp, ans); } } pw.println(ans); pw.close(); sc.close(); } }