結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー | 37zigen |
提出日時 | 2016-07-16 13:49:21 |
言語 | Java19 (openjdk 21) |
結果 |
AC
|
実行時間 | 168 ms / 2,000 ms |
コード長 | 1,254 bytes |
コンパイル時間 | 3,853 ms |
コンパイル使用メモリ | 73,240 KB |
実行使用メモリ | 56,476 KB |
最終ジャッジ日時 | 2023-08-05 16:38:47 |
合計ジャッジ時間 | 9,096 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 125 ms
55,704 KB |
testcase_01 | AC | 123 ms
55,676 KB |
testcase_02 | AC | 124 ms
56,028 KB |
testcase_03 | AC | 123 ms
55,940 KB |
testcase_04 | AC | 123 ms
55,644 KB |
testcase_05 | AC | 124 ms
55,856 KB |
testcase_06 | AC | 124 ms
55,844 KB |
testcase_07 | AC | 123 ms
55,868 KB |
testcase_08 | AC | 162 ms
56,260 KB |
testcase_09 | AC | 137 ms
53,584 KB |
testcase_10 | AC | 158 ms
56,184 KB |
testcase_11 | AC | 146 ms
55,468 KB |
testcase_12 | AC | 140 ms
56,008 KB |
testcase_13 | AC | 168 ms
56,476 KB |
testcase_14 | AC | 132 ms
55,472 KB |
testcase_15 | AC | 134 ms
55,624 KB |
testcase_16 | AC | 149 ms
55,828 KB |
testcase_17 | AC | 152 ms
53,920 KB |
testcase_18 | AC | 151 ms
55,896 KB |
testcase_19 | AC | 150 ms
55,904 KB |
testcase_20 | AC | 145 ms
55,728 KB |
testcase_21 | AC | 134 ms
55,912 KB |
testcase_22 | AC | 160 ms
56,072 KB |
testcase_23 | AC | 162 ms
56,244 KB |
testcase_24 | AC | 161 ms
56,016 KB |
testcase_25 | AC | 161 ms
56,136 KB |
testcase_26 | AC | 161 ms
55,596 KB |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { solver(); } static void solver() { int INF = Integer.MAX_VALUE / 4; Scanner sc = new Scanner(System.in); int gx = sc.nextInt(); int gy = sc.nextInt(); int n = sc.nextInt(); int f = sc.nextInt(); int[] x = new int[n]; int[] y = new int[n]; int[] c = new int[n]; for (int i = 0; i < n; i++) { x[i] = sc.nextInt(); y[i] = sc.nextInt(); c[i] = sc.nextInt(); } int[][] map = new int[101][101]; for (int i = 0; i <= 100; i++) { for (int j = 0; j <= 100; j++) { map[i][j] = INF; } } map[0][0] = 0; long ans = f * (gx + gy); for (int i = 0; i < n; i++) { if (c[i] < (x[i] + y[i]) * f) { for (int sum = gx + gy; sum >= 0; sum--) { for (int xx = gx; xx >= 0; xx--) { int yy = sum - gx; if (yy < 0 || yy > gy) continue; if (map[xx][yy] != INF) { if (xx + x[i] <= gx && yy + y[i] <= gy) { map[xx + x[i]][yy + y[i]] = Math.min(map[xx][yy] + c[i], map[xx + x[i]][yy + y[i]]); ans = Math.min(ans, f * (gx + gy - xx - yy - x[i] - y[i]) + map[xx + x[i]][yy + y[i]]); } } } } } else { continue; } } System.out.println(ans); } }