結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー | tenten |
提出日時 | 2020-12-10 11:33:53 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,808 bytes |
コンパイル時間 | 3,490 ms |
コンパイル使用メモリ | 78,224 KB |
実行使用メモリ | 64,316 KB |
最終ジャッジ日時 | 2023-10-19 23:19:46 |
合計ジャッジ時間 | 10,764 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 134 ms
57,688 KB |
testcase_01 | AC | 137 ms
57,508 KB |
testcase_02 | AC | 137 ms
57,512 KB |
testcase_03 | AC | 136 ms
55,448 KB |
testcase_04 | WA | - |
testcase_05 | AC | 140 ms
57,536 KB |
testcase_06 | AC | 168 ms
57,520 KB |
testcase_07 | AC | 136 ms
57,332 KB |
testcase_08 | AC | 397 ms
64,316 KB |
testcase_09 | AC | 396 ms
64,072 KB |
testcase_10 | AC | 159 ms
57,668 KB |
testcase_11 | AC | 159 ms
57,784 KB |
testcase_12 | AC | 186 ms
57,772 KB |
testcase_13 | AC | 184 ms
55,628 KB |
testcase_14 | AC | 210 ms
59,692 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 203 ms
57,684 KB |
testcase_19 | WA | - |
testcase_20 | AC | 177 ms
57,780 KB |
testcase_21 | AC | 161 ms
57,336 KB |
testcase_22 | WA | - |
testcase_23 | AC | 268 ms
61,648 KB |
testcase_24 | AC | 262 ms
62,884 KB |
testcase_25 | AC | 255 ms
62,816 KB |
testcase_26 | AC | 271 ms
61,484 KB |
ソースコード
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[] xArr = new int[n]; int[] yArr = new int[n]; int[] cArr = new int[n]; for (int i = 0; i < n; i++) { xArr[i] = sc.nextInt(); yArr[i] = sc.nextInt(); cArr[i] = sc.nextInt(); } int[][] costs = new int[gx + 1][gy + 1]; for (int[] arr : costs) { Arrays.fill(arr, Integer.MAX_VALUE); } PriorityQueue<Path> queue = new PriorityQueue<>(); queue.add(new Path(0, 0, 0)); while (queue.size() > 0) { Path p = queue.poll(); if (costs[p.x][p.y] <= p.value) { continue; } costs[p.x][p.y] = p.value; if (p.x < gx) { queue.add(new Path(p.x + 1, p.y, p.value + f)); } if (p.y < gy) { queue.add(new Path(p.x, p.y + 1, p.value + f)); } for (int i = 0; i < n; i++) { if (p.x + xArr[i] <= gx && p.y + yArr[i] <= gy) { queue.add(new Path(p.x + xArr[i], p.y + yArr[i], p.value + cArr[i])); } } } System.out.println(costs[gx][gy]); } static class Path implements Comparable<Path> { int x; int y; int value; public Path(int x, int y, int value) { this.x = x; this.y = y; this.value = value; } public int compareTo(Path another) { return value - another.value; } } }