結果
| 問題 |
No.496 ワープクリスタル (給料日前編)
|
| コンテスト | |
| ユーザー |
uafr_cs
|
| 提出日時 | 2017-03-24 22:47:34 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 163 ms / 2,000 ms |
| コード長 | 1,237 bytes |
| コンパイル時間 | 2,016 ms |
| コンパイル使用メモリ | 76,596 KB |
| 実行使用メモリ | 41,596 KB |
| 最終ジャッジ日時 | 2024-07-05 22:13:39 |
| 合計ジャッジ時間 | 6,678 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
final int gx = sc.nextInt();
final int gy = sc.nextInt();
final int N = sc.nextInt();
final int F = sc.nextInt();
int[] xs = new int[N];
int[] ys = new int[N];
int[] cs = new int[N];
for(int i = 0; i < N; i++){
final int x = sc.nextInt();
final int y = sc.nextInt();
final int c = sc.nextInt();
xs[i] = x;
ys[i] = y;
cs[i] = c;
}
long[][] DP = new long[gy + 1][gx + 1];
for(int y = 0; y <= gy; y++){
for(int x = 0; x <= gx; x++){
DP[y][x] = (y + x) * F;
}
}
for(int index = 0; index < N; index++){
for(int y = gy; y >= 0; y--){
final int ny = y - ys[index];
if(ny < 0){ continue; }
for(int x = gx; x >= 0; x--){
final int nx = x - xs[index];
if(nx < 0){ continue; }
DP[y][x] = Math.min(DP[y][x], DP[ny][nx] + cs[index]);
}
}
}
/*
for(int y = 0; y <= gy; y++){
for(int x = 0; x <= gx; x++){
System.out.print(DP[y][x] + " ");
}
System.out.println();
}
//*/
System.out.println(DP[gy][gx]);
}
}
uafr_cs