結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー pekempeypekempey
提出日時 2017-03-24 22:26:51
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 826 ms
コンパイル使用メモリ 75,932 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-06 02:54:27
合計ジャッジ時間 1,292 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>

using namespace std;

int dp[101][101];

int main() {
	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 101; j++) {
			dp[i][j] = 1e9;
		}
	}
	int gx, gy, n, f;
	cin >> gx >> gy >> n >> f;
	dp[0][0] = 0;
	while (n--) {
		int x, y, c;
		cin >> x >> y >> c;
		for (int i = gx - x; i >= 0; i--) {
			for (int j = gy - y; j >= 0; j--) {
				dp[i + x][j + y] = min(dp[i + x][j + y], dp[i][j] + c);
			}
		}
	}
	int ans = 1e9;
	for (int i = 0; i <= gx; i++) {
		for (int j = 0; j <= gy; j++) {
			ans = min(ans, dp[i][j] + f * (abs(gx - i) + abs(gy - j)));
		}
	}
	cout << ans << endl;
}
0