結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー dnishdnish
提出日時 2017-07-12 02:22:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 620 bytes
コンパイル時間 1,324 ms
コンパイル使用メモリ 166,028 KB
実行使用メモリ 5,240 KB
最終ジャッジ日時 2023-07-29 10:33:33
合計ジャッジ時間 2,282 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 3 ms
4,376 KB
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 AC 1 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define p(s) cout<<(s)<<endl
using namespace std;
const int inf=1e9;

int dp[110][110];
int x[55],y[55],c[55];
int main(){
	int gx,gy,N,F;
	cin>>gx>>gy>>N>>F;
	REP(i,0,N)	cin>>x[i]>>y[i]>>c[i];
	REP(i,0,gx+1) REP(j,0,gy+1) dp[i][j]=inf;
	dp[0][0]=0;
	REP(i,0,gx) REP(j,0,gy)	REP(k,0,N)	{
		if(i+x[k]>gx||i+y[k]>gy) continue;
		dp[i+x[k]][j+y[k]]=min(dp[i+x[k]][j+y[k]],dp[i][j]+c[k]);
	}
	REP(i,0,gx+1) REP(j,0,gy+1){
		if(j>0)dp[i][j]=min(dp[i][j],dp[i][j-1]+F);
		else if(i>0) dp[i][j]=min(dp[i][j],dp[i-1][j]+F);
	}
	p(dp[gx][gy]);
	return 0;
}
0