結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー ふっぴーふっぴー
提出日時 2017-03-24 23:15:20
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 858 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 31,348 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-20 03:38:08
合計ジャッジ時間 2,190 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 0 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 0 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stdlib.h>
#define INF 1000000000;

int min(int a,int b);
int main(void){
	int gx,gy,n,f;
	scanf("%d %d %d %d",&gx,&gy,&n,&f);
	int x[50],y[50],c[50];
	int i,j,k;
	for(i=0;i<n;i++){
		scanf("%d %d %d",&x[i],&y[i],&c[i]);
	}
	unsigned long dp[gx+1][gy+1];
	for(j=0;j<=gx;j++){
		for(k=0;k<=gy;k++){
			dp[j][k]=INF;
		}
	}
	dp[0][0]=0;
	for(i=0;i<n;i++){
		for(j=0;j<=gx;j++){
			for(k=0;k<=gy;k++){
				if(j+x[i]<=gx && k+y[i]<=gy){
					dp[j+x[i]][k+y[i]]=min(dp[j][k]+c[i],dp[j+x[i]][k+y[i]]);
				}
			}
		}
	}
	unsigned long min=INF;
	for(j=0;j<=gx;j++){
		for(k=0;k<=gy;k++){
			dp[j][k]=dp[j][k]+f*(gx-j+gy-k);
			if(min>dp[j][k]){
				min=dp[j][k];
			}
		}
	}
	printf("%lu\n",min);
	return 0;
}

int min(int a,int b){
	if(a<=b){
		return a;
	}else{
		return b;
	}
}
0