結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー ふっぴーふっぴー
提出日時 2017-03-25 00:53:14
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 804 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 31,012 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-20 07:25:56
合計ジャッジ時間 2,469 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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=gx;j>=0;j--){
			for(k=gy;k>=0;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 ans=INF;
	for(j=0;j<=gx;j++){
		for(k=0;k<=gy;k++){
			ans=min(ans,dp[j][k]);
		}
	}
	printf("%lu\n",min);
	return 0;
}

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