結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー | mosmos_21 |
提出日時 | 2017-06-20 10:50:15 |
言語 | Java21 (openjdk 21) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,360 bytes |
コンパイル時間 | 2,170 ms |
コンパイル使用メモリ | 77,772 KB |
実行使用メモリ | 58,332 KB |
最終ジャッジ日時 | 2024-04-10 02:12:29 |
合計ジャッジ時間 | 7,071 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 126 ms
53,940 KB |
testcase_01 | AC | 124 ms
54,028 KB |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | AC | 116 ms
53,112 KB |
testcase_06 | AC | 122 ms
54,100 KB |
testcase_07 | AC | 123 ms
53,824 KB |
testcase_08 | AC | 189 ms
56,632 KB |
testcase_09 | AC | 188 ms
56,684 KB |
testcase_10 | RE | - |
testcase_11 | AC | 136 ms
53,736 KB |
testcase_12 | AC | 142 ms
53,860 KB |
testcase_13 | RE | - |
testcase_14 | AC | 149 ms
54,148 KB |
testcase_15 | AC | 140 ms
54,232 KB |
testcase_16 | RE | - |
testcase_17 | AC | 163 ms
54,476 KB |
testcase_18 | AC | 143 ms
54,064 KB |
testcase_19 | AC | 139 ms
53,964 KB |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | AC | 170 ms
56,472 KB |
testcase_23 | AC | 166 ms
56,352 KB |
testcase_24 | WA | - |
testcase_25 | AC | 172 ms
56,480 KB |
testcase_26 | AC | 173 ms
56,440 KB |
ソースコード
import java.util.Scanner; public class Main { static Scanner in = new Scanner(System.in); public static void main(String[] args) { int Gx = in.nextInt(), Gy = in.nextInt(), N = in.nextInt(), F = in.nextInt(); int[] x = new int[N], y = new int[N], c = new int[N]; for (int i = 0; i < N; i++) { x[i] = in.nextInt(); y[i] = in.nextInt(); c[i] = in.nextInt(); } int[][][] dp = new int[N + 1][Gx + 1][Gy + 1]; for(int i = 0; i < Gx + 1; i++){ for(int j = 0; j < Gy + 1; j++){ dp[0][i][j] = (i + j) * F; } } for(int i = 1; i < N + 1; i++){ for(int j = 0; j < Gx + 1; j++){ for(int k = 0; k < Gy + 1; k++){ if(j != 0){ dp[i][j][k] = Math.min(dp[i - 1][j][j], dp[i - 1][j - 1][k] + F); } if(k != 0){ dp[i][j][k] = Math.min(dp[i - 1][j][k], dp[i - 1][j][k - 1] + F); } if(j - x[i - 1] >= 0 && k - y[i - 1] >= 0){ dp[i][j][k] = Math.min(dp[i - 1][j][k], dp[i - 1][j - x[i - 1]][k - y[i - 1]] + c[i - 1]); } } } } System.out.println(dp[N][Gx][Gy]); } }