結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー snrnsidysnrnsidy
提出日時 2021-09-16 22:17:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,021 bytes
コンパイル時間 2,282 ms
コンパイル使用メモリ 199,144 KB
実行使用メモリ 5,440 KB
最終ジャッジ日時 2023-09-12 04:15:09
合計ジャッジ時間 4,651 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int X[50];
int Y[50];
int C[50];
int gx,gy,n,f;
int dp[51][101][101];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> gx >> gy >> n >> f;

	for(int i=0;i<n;i++)
	{
		cin >> X[i] >> Y[i] >> C[i];
	}

	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=100;j++)
		{
			for(int k=0;k<=100;k++)
			{
				dp[i][j][k] = 1e9;
			}
		}
	}

	dp[0][0][0] = 0;

	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=100;j++)
		{
			for(int k=0;k<=100;k++)
			{
				if(dp[i][j][k]>=1e9) continue;
				if(j+1<=100)
				{
					dp[i][j+1][k] = min(dp[i][j+1][k],dp[i][j][k] + f);
				}
				if(k+1<=100)
				{
					dp[i][j][k+1] = min(dp[i][j][k+1],dp[i][j][k] + f);
				}
				if(i < n && j+X[i]<=100 && k+Y[i]<=100)
				{
					dp[i+1][j+X[i]][k+Y[i]] = min(dp[i+1][j+X[i]][k+Y[i]],dp[i][j][k] + C[i]);
				}
				dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
			}
		}
	}

	int res = 1e9;

	for(int i=0;i<=n;i++)
	{
		res = min(res,dp[i][gx][gy]);
	}

	cout << res << '\n';
	return 0;
}
0