結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー moririn2528_cmoririn2528_c
提出日時 2017-03-24 22:57:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 53,204 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-20 02:38:31
合計ジャッジ時間 2,013 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,388 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 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
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:11: warning: ‘k’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   cr[k][3]=0;
   ~~~~~~~~^~

ソースコード

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];
		}
		cr[k][3]=0;
	}
	for(i=0;i<105;i++){
		for(j=0;j<105;j++){
			dp[i][j]=MAX;
		}
	}
	dp[0][0]=0;
	for(k=0;k<n;k++){
		for(i=x;i>=0;i--){
			for(j=y;j>=0;j--){
				if(i<cr[k][0] || j<cr[k][1])continue;
				dp[i][j]=min(dp[i][j],dp[i-cr[k][0]][j-cr[k][1]]+cr[k][2]);
			}
		}
	}
	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);
		}
	}
	cout<<dp[x][y]<<endl;
	return 0;
}
0