結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー | shinwisteria |
提出日時 | 2017-03-24 23:58:01 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 983 bytes |
コンパイル時間 | 5,632 ms |
コンパイル使用メモリ | 73,976 KB |
実行使用メモリ | 58,260 KB |
最終ジャッジ日時 | 2023-09-20 05:56:21 |
合計ジャッジ時間 | 11,890 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 127 ms
55,340 KB |
testcase_01 | AC | 126 ms
55,572 KB |
testcase_02 | AC | 129 ms
55,848 KB |
testcase_03 | AC | 126 ms
55,556 KB |
testcase_04 | WA | - |
testcase_05 | AC | 131 ms
55,628 KB |
testcase_06 | AC | 191 ms
55,944 KB |
testcase_07 | AC | 128 ms
55,648 KB |
testcase_08 | AC | 297 ms
56,028 KB |
testcase_09 | AC | 221 ms
56,124 KB |
testcase_10 | AC | 142 ms
55,852 KB |
testcase_11 | AC | 145 ms
55,952 KB |
testcase_12 | AC | 173 ms
56,040 KB |
testcase_13 | AC | 157 ms
55,864 KB |
testcase_14 | AC | 166 ms
56,252 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 191 ms
56,500 KB |
testcase_19 | WA | - |
testcase_20 | AC | 191 ms
55,932 KB |
testcase_21 | AC | 154 ms
56,184 KB |
testcase_22 | WA | - |
testcase_23 | AC | 252 ms
55,712 KB |
testcase_24 | AC | 300 ms
56,300 KB |
testcase_25 | AC | 295 ms
55,580 KB |
testcase_26 | AC | 255 ms
55,568 KB |
ソースコード
import java.util.Scanner; public class WarpCristal { public static void main(String[] args) { Scanner s = new Scanner(System.in); int Gx = s.nextInt(),Gy = s.nextInt(),N = s.nextInt(),F = s.nextInt(); int[][] cost = new int[Gx+1][Gy+1]; int[][] d = new int[Gx+1][Gy+1]; int[][] anti = new int[Gx+1][Gy+1]; for(int i = 0;i < N;i++){ d[s.nextInt()][s.nextInt()] = s.nextInt(); } int sx = 0,sy = 0; s.close(); for(int i = sx;i <= Gx;i++){ for(int j = sy;j <= Gy;j++){ cost[i][j] = (i+j)*F; for(int x = 0;x <= i;x++){ for(int y = 0;y <= j;y++){ if(d[x][y] != 0 && cost[i][j] > cost[i-x][j-y] + d[x][y]){ cost[i][j] = cost[i-x][j-y] + d[x][y]; anti[x][y] = d[x][y]; d[x][y] = 0; } if(anti[x][y] != 0&& cost[i][j] > cost[i-x][j-y]){ cost[i][j] = cost[i-x][j-y] + anti[x][y]; d[x][y] = anti[x][y]; anti[x][y] = 0; } } } } } System.out.println(cost[Gx][Gy]); } }