結果
問題 | No.1 道のショートカット |
ユーザー | yuki2006 |
提出日時 | 2014-10-01 19:26:30 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,324 bytes |
コンパイル時間 | 4,810 ms |
コンパイル使用メモリ | 79,984 KB |
実行使用メモリ | 61,264 KB |
最終ジャッジ日時 | 2023-09-22 11:42:17 |
合計ジャッジ時間 | 12,930 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 124 ms
55,492 KB |
testcase_01 | AC | 123 ms
55,744 KB |
testcase_02 | AC | 124 ms
55,840 KB |
testcase_03 | AC | 129 ms
55,716 KB |
testcase_04 | WA | - |
testcase_05 | AC | 124 ms
55,888 KB |
testcase_06 | AC | 131 ms
55,928 KB |
testcase_07 | AC | 139 ms
55,772 KB |
testcase_08 | AC | 225 ms
59,156 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 123 ms
55,940 KB |
testcase_16 | WA | - |
testcase_17 | AC | 124 ms
55,476 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 183 ms
54,556 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 123 ms
55,700 KB |
testcase_43 | AC | 124 ms
55,844 KB |
ソースコード
import java.util.ArrayList; import java.util.Arrays; import java.util.Random; import java.util.Scanner; public class Yuki001 { public static void main(String[] args) { ArrayList<Integer> si = new ArrayList<Integer>(); ArrayList<Integer> ti = new ArrayList<Integer>(); ArrayList<Integer> ci = new ArrayList<Integer>(); ArrayList<Integer> tis = new ArrayList<Integer>(); Scanner scanner = new Scanner(System.in); int N; int C; N = scanner.nextInt(); C = scanner.nextInt(); int[][] cost = new int[N + 1][N + 1]; int[][] time = new int[N + 1][N + 1]; int V = scanner.nextInt(); for (int i = 0; i < V; i++) { si.add(scanner.nextInt()); } for (int i = 0; i < V; i++) { ti.add(scanner.nextInt()); } for (int i = 0; i < V; i++) { cost[ti.get(i)][si.get(i)] = scanner.nextInt(); } for (int i = 0; i < V; i++) { time[ti.get(i)][si.get(i)] = scanner.nextInt(); } int MAX = Integer.MAX_VALUE / 2; int[][] dp = new int[N + 1][C + 1]; for (int i = 0; i < dp.length; i++) { Arrays.fill(dp[i], MAX); } dp[1][C] = 0; for (int i = 2; i < N + 1; i++) { for (int k = 1; k < i; k++) { if (cost[i][k] == 0) { break; } for (int t = 0; t <= C; t++) { if (dp[k][t] >= MAX) { continue; } int c = t - cost[i][k]; if (c < 0) { continue; } dp[i][c] = Math.min(dp[i][c], dp[k][t] + time[i][k]); } } } int min = Integer.MAX_VALUE; for (int i = C; i >= 0; i--) { if (dp[N][i] != MAX) { min = Math.min(min, dp[N][i]); } } if (min == Integer.MAX_VALUE) { System.out.println(-1); } else { System.out.println(min); } } static String wrap(ArrayList<? extends Object> list) { return list.toString().replace("[", "").replace("]", "").replace(",", ""); } }