結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー moririn2528_cmoririn2528_c
提出日時 2017-03-24 22:47:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 52,892 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 01:53:26
合計ジャッジ時間 1,403 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#define min(a,b) a<b?a:b
using namespace std;
int dp[105][105];
const int MAX=100007;
int main(){
	int x,y,n,f;
	int cr[55][4];
	int i,j,k;
	cin>>x>>y>>n>>f;
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			cin>>cr[i][j];
		}
	}
	for(i=0;i<105;i++){
		for(j=0;j<105;j++){
			dp[i][j]=MAX;
		}
	}
	dp[0][0]=0;
	for(i=0;i<=x;i++){
		for(j=0;j<=y;j++){
			if(i!=0)dp[i][j]=min(dp[i][j],dp[i-1][j]+f);
			if(j!=0)dp[i][j]=min(dp[i][j],dp[i][j-1]+f);
			for(k=0;k<n;k++){
				if(i<cr[k][0] || j<cr[k][1] || cr[k][3]==1)continue;
				cr[k][3]=1;
				dp[i][j]=min(dp[i][j],dp[i-cr[k][0]][j-cr[k][1]]+cr[k][2]);
			}
		}
	}
	cout<<dp[x][y]<<endl;
	return 0;
}
0