結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-03-24 22:45:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 933 bytes
コンパイル時間 1,635 ms
コンパイル使用メモリ 165,608 KB
実行使用メモリ 5,708 KB
最終ジャッジ日時 2023-09-20 01:52:11
合計ジャッジ時間 2,381 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)




int GX, GY, N, F;
int X[60], Y[60], C[60];
//-----------------------------------------------------------------------------------
#define INF INT_MAX/2
int dp[101][101][101];
int main() {
	cin >> GX >> GY >> N >> F;
	rep(i, 0, N) cin >> X[i] >> Y[i] >> C[i];

	rep(i, 0, N) if ((X[i] + Y[i]) * F < C[i]) C[i] = (X[i] + Y[i]) * F;

	rep(i, 0, N + 1) rep(y, 0, GY + 1) rep(x, 0, GX + 1) dp[i][y][x] = INF;
	dp[0][0][0] = 0;
	rep(i, 0, N) rep(y, 0, GY + 1) rep(x, 0, GX + 1) {
		dp[i + 1][y][x] = min(dp[i + 1][y][x], dp[i][y][x]);
		int xx = x + X[i];
		int yy = y + Y[i];
		if (GX < xx) continue;
		if (GY < yy) continue;
		dp[i + 1][yy][xx] = min(dp[i + 1][yy][xx], dp[i][y][x] + C[i]);
	}

	int ans = INF;
	rep(y, 0, GY + 1) rep(x, 0, GX + 1) {
		int c = ((GY - y) + (GX - x)) * F + dp[N][y][x];
		ans = min(ans, c);
	}

	cout << ans << endl;
}
0