結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー 37zigen37zigen
提出日時 2016-07-16 13:38:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,175 bytes
コンパイル時間 2,152 ms
コンパイル使用メモリ 77,168 KB
実行使用メモリ 41,976 KB
最終ジャッジ日時 2024-04-23 13:42:51
合計ジャッジ時間 7,066 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,212 KB
testcase_01 AC 133 ms
41,560 KB
testcase_02 AC 133 ms
41,300 KB
testcase_03 AC 134 ms
41,276 KB
testcase_04 WA -
testcase_05 AC 139 ms
41,564 KB
testcase_06 AC 131 ms
41,140 KB
testcase_07 AC 134 ms
41,376 KB
testcase_08 AC 152 ms
41,544 KB
testcase_09 AC 146 ms
41,584 KB
testcase_10 AC 147 ms
41,676 KB
testcase_11 AC 146 ms
41,408 KB
testcase_12 AC 144 ms
41,740 KB
testcase_13 AC 150 ms
41,680 KB
testcase_14 AC 140 ms
41,416 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 144 ms
41,220 KB
testcase_19 WA -
testcase_20 AC 138 ms
41,512 KB
testcase_21 AC 141 ms
41,636 KB
testcase_22 WA -
testcase_23 AC 158 ms
41,388 KB
testcase_24 AC 153 ms
41,476 KB
testcase_25 AC 154 ms
41,696 KB
testcase_26 AC 151 ms
41,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 xx = 0; xx <= gx; xx++) {
					for (int yy = 0; yy <= gy; yy++) {
						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);
	}
}
0