結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー mogurockermogurocker
提出日時 2017-10-16 16:29:48
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,120 bytes
コンパイル時間 1,460 ms
コンパイル使用メモリ 165,532 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 23:32:39
合計ジャッジ時間 2,339 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

pair<int, P> dp[55][55];
int gx, gy, n, f;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> gx >> gy >> n >> f;
	FOR(i, n+1) FOR(j, n+1) dp[i][j] = {(gx+gy)*f, {0, 0}};
	for (int i = 1; i <= n; i++) {
		int dx, dy, c;
		cin >> dx >> dy >> c;
		for (int j = 1; j <= i; j++) {
			if (dp[i][j].first > dp[i-1][j].first) {
				dp[i][j] = {dp[i-1][j].first, {dp[i-1][j].second.first, dp[i-1][j].second.second}};
			}
			int px = dp[i-1][j-1].second.first, py = dp[i-1][j-1].second.second;
			int nx = px + dx, ny = py + dy;
			if (nx > gx || ny > gy) continue;
			if (dp[i][j].first > dp[i-1][j-1].first - (gx-px+gy-py)*f + c + (gx-nx+gy-ny)*f) {
				dp[i][j] = {dp[i-1][j-1].first - (gx-px+gy-py)*f + c + (gx-nx+gy-ny)*f, {nx, ny}};
			}
			
		}
	}
	sort(dp[n], dp[n]+n+1);
	cout << dp[n][0].first << endl;
	return 0;
}
0