結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー uafr_csuafr_cs
提出日時 2017-03-24 22:40:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,372 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 73,748 KB
実行使用メモリ 58,248 KB
最終ジャッジ日時 2023-09-20 01:41:16
合計ジャッジ時間 6,922 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,988 KB
testcase_01 AC 121 ms
55,928 KB
testcase_02 AC 121 ms
55,936 KB
testcase_03 AC 122 ms
55,848 KB
testcase_04 WA -
testcase_05 AC 121 ms
55,876 KB
testcase_06 AC 119 ms
55,916 KB
testcase_07 AC 120 ms
55,536 KB
testcase_08 AC 164 ms
56,640 KB
testcase_09 AC 164 ms
56,600 KB
testcase_10 AC 136 ms
55,868 KB
testcase_11 AC 135 ms
56,484 KB
testcase_12 AC 133 ms
55,952 KB
testcase_13 AC 130 ms
56,312 KB
testcase_14 AC 130 ms
56,220 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 135 ms
56,048 KB
testcase_19 WA -
testcase_20 AC 124 ms
55,952 KB
testcase_21 AC 127 ms
56,140 KB
testcase_22 WA -
testcase_23 AC 151 ms
56,152 KB
testcase_24 AC 149 ms
56,212 KB
testcase_25 AC 151 ms
56,032 KB
testcase_26 AC 153 ms
56,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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] = (x + y) * F;
			}
		}
		/*
		for(int y = 0; y <= gy; y++){
			for(int x = 0; x <= gy; x++){
				System.out.print(DP[y][x]);
			}
			System.out.println();
		}
		//*/
		
		for(int index = 0; index < N; index++){
			for(int y = 0; y <= gy; y++){
				final int ny = y + ys[index];
				if(ny > gy){ break; }
				
				for(int x = 0; x <= gx; x++){
					final int nx = x + xs[index];
					if(nx > gx){ break; }
					
					DP[ny][nx] = Math.min(DP[ny][nx], DP[y][x] + 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]);
	}
}
0