結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー snrnsidysnrnsidy
提出日時 2021-09-16 22:18:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,046 bytes
コンパイル時間 1,967 ms
コンパイル使用メモリ 198,376 KB
実行使用メモリ 5,516 KB
最終ジャッジ日時 2023-09-12 04:15:18
合計ジャッジ時間 3,159 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 6 ms
5,516 KB
testcase_09 AC 6 ms
5,428 KB
testcase_10 AC 6 ms
5,452 KB
testcase_11 AC 6 ms
5,504 KB
testcase_12 AC 6 ms
5,012 KB
testcase_13 AC 5 ms
4,548 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 4 ms
4,440 KB
testcase_17 AC 4 ms
4,436 KB
testcase_18 AC 3 ms
4,384 KB
testcase_19 AC 4 ms
4,388 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 6 ms
5,456 KB
testcase_23 AC 6 ms
5,404 KB
testcase_24 AC 5 ms
5,396 KB
testcase_25 AC 5 ms
5,400 KB
testcase_26 AC 6 ms
5,396 KB
権限があれば一括ダウンロードができます

ソースコード

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]);
				}
				if(i<n)
				{
					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