結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー shinwisteriashinwisteria
提出日時 2017-04-02 23:27:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 974 bytes
コンパイル時間 3,521 ms
コンパイル使用メモリ 75,836 KB
実行使用メモリ 56,376 KB
最終ジャッジ日時 2023-09-22 07:50:44
合計ジャッジ時間 8,936 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
55,632 KB
testcase_01 AC 135 ms
55,584 KB
testcase_02 AC 134 ms
55,692 KB
testcase_03 AC 133 ms
55,732 KB
testcase_04 AC 135 ms
55,784 KB
testcase_05 AC 133 ms
55,632 KB
testcase_06 AC 131 ms
55,956 KB
testcase_07 AC 130 ms
55,516 KB
testcase_08 AC 208 ms
56,108 KB
testcase_09 AC 146 ms
55,576 KB
testcase_10 AC 150 ms
55,648 KB
testcase_11 AC 148 ms
55,896 KB
testcase_12 AC 149 ms
55,512 KB
testcase_13 AC 148 ms
55,904 KB
testcase_14 AC 140 ms
55,696 KB
testcase_15 AC 146 ms
55,356 KB
testcase_16 AC 148 ms
55,536 KB
testcase_17 AC 167 ms
56,252 KB
testcase_18 AC 154 ms
55,632 KB
testcase_19 AC 155 ms
55,760 KB
testcase_20 AC 151 ms
55,744 KB
testcase_21 AC 144 ms
55,748 KB
testcase_22 AC 177 ms
55,864 KB
testcase_23 AC 182 ms
56,164 KB
testcase_24 AC 177 ms
56,252 KB
testcase_25 AC 180 ms
55,956 KB
testcase_26 AC 178 ms
56,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;

public class WarpCrystal {

	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();
		ArrayList<Integer> cx = new ArrayList<>();
		ArrayList<Integer> cy = new ArrayList<>();
		ArrayList<Integer> cc = new ArrayList<>();
		for(int i = 0;i < N;i++){
			int x = s.nextInt(),y = s.nextInt(),c = s.nextInt();
			if(c < (x+y)*F){
				cx.add(x);
				cy.add(y);
				cc.add(c);
			}
		}
		s.close();
		int[][] mas = new int[Gx+1][Gy+1];
		for(int i =0;i <= Gx;i++){
			for(int j = 0;j <= Gy;j++){
				mas[i][j] = (i + j) * F;
			}
		}
		for(int i = 0;i < cx.size();i++){
			for(int j = Gx;j >= 0;j--){
				for(int k = Gy;k >= 0;k--){
					if(j - cx.get(i) >= 0 && k -cy.get(i) >= 0){
						mas[j][k] = Math.min(mas[j][k], mas[j-cx.get(i)][k-cy.get(i)]+cc.get(i));
					}
				}
			}
		}
		System.out.println(mas[Gx][Gy]);
	} 
}
0