結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー eiya5498513eiya5498513
提出日時 2017-03-26 16:28:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,293 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 74,760 KB
実行使用メモリ 6,028 KB
最終ジャッジ日時 2023-09-20 11:04:02
合計ジャッジ時間 1,756 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X;}
#define TF(f) {f;}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1000000;
int dp[52][110][110];
bool vis[52][110][110];
int X[100], Y[100], c[100];
int N, F, Gx, Gy, ans;

int dfs(int n, int x, int y) {
	if (n == -1) { return (x + y)*F; }
	if (vis[n][x][y]) {
		return dp[n][x][y];
	}
	else vis[n][x][y] = true;

	if (x >= X[n] && y >= Y[n])
	{
		dp[n][x][y] = min(dfs(n - 1, x - X[n], y - Y[n]) + c[n], dfs(n - 1, x, y));
		/*DEB(n)DEB(x)DEB(y)END
		DEB(dfs(n-1,x-X[n],y-Y[n])+c[n])DEB(dfs(n-1,x,y))END END*/
	}
	else { dp[n][x][y] = dfs(n - 1, x, y);/*DEB(dfs(n-1,x,y))END*/ }

	return dp[n][x][y];

}
int main() {
	ios_base::sync_with_stdio(false);
	cin >> Gx >> Gy >> N >> F;
	REP(i, N)cin >> X[i] >> Y[i] >> c[i];
	cout << dfs(N-1, Gx, Gy) << endl;

	return 0;
}
0