結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー tentententen
提出日時 2020-12-10 11:45:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 867 bytes
コンパイル時間 2,145 ms
コンパイル使用メモリ 77,328 KB
実行使用メモリ 57,804 KB
最終ジャッジ日時 2023-10-19 23:29:49
合計ジャッジ時間 7,197 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
57,408 KB
testcase_01 AC 137 ms
57,516 KB
testcase_02 AC 135 ms
57,508 KB
testcase_03 AC 135 ms
57,528 KB
testcase_04 AC 133 ms
57,576 KB
testcase_05 AC 134 ms
57,648 KB
testcase_06 AC 134 ms
55,456 KB
testcase_07 AC 134 ms
57,732 KB
testcase_08 AC 167 ms
57,744 KB
testcase_09 AC 164 ms
57,804 KB
testcase_10 AC 150 ms
57,772 KB
testcase_11 AC 151 ms
57,672 KB
testcase_12 AC 146 ms
57,640 KB
testcase_13 AC 147 ms
57,660 KB
testcase_14 AC 143 ms
57,780 KB
testcase_15 AC 141 ms
57,544 KB
testcase_16 AC 143 ms
57,668 KB
testcase_17 AC 142 ms
57,668 KB
testcase_18 AC 146 ms
57,576 KB
testcase_19 AC 142 ms
57,620 KB
testcase_20 AC 141 ms
57,640 KB
testcase_21 AC 142 ms
57,664 KB
testcase_22 AC 162 ms
57,728 KB
testcase_23 AC 168 ms
57,712 KB
testcase_24 AC 169 ms
57,744 KB
testcase_25 AC 164 ms
57,720 KB
testcase_26 AC 165 ms
57,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int gx = sc.nextInt();
        int gy = sc.nextInt();
        int n = sc.nextInt();
        int f = sc.nextInt();
        int[][] costs = new int[gx + 1][gy + 1];
        for (int i = 0; i <= gx; i++) {
            for (int j = 0; j <= gy; j++) {
                costs[i][j] = (i + j) * f;
            }
        }
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int c = sc.nextInt();
            for (int j = gx; j - x >= 0; j--) {
                for (int k = gy; k - y >= 0; k--) {
                    costs[j][k] = Math.min(costs[j][k], costs[j - x][k - y] + c);
                }
            }
        }
        System.out.println(costs[gx][gy]);
    }
}
0