結果
問題 |
No.496 ワープクリスタル (給料日前編)
|
ユーザー |
![]() |
提出日時 | 2020-12-10 11:45:00 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 146 ms / 2,000 ms |
コード長 | 867 bytes |
コンパイル時間 | 1,968 ms |
コンパイル使用メモリ | 76,812 KB |
実行使用メモリ | 41,988 KB |
最終ジャッジ日時 | 2024-09-19 19:23:54 |
合計ジャッジ時間 | 5,965 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
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]); } }