結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー femtofemto
提出日時 2017-03-24 23:02:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,019 bytes
コンパイル時間 1,494 ms
コンパイル使用メモリ 166,456 KB
実行使用メモリ 5,948 KB
最終ジャッジ日時 2023-09-20 02:49:25
合計ジャッジ時間 2,508 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,720 KB
testcase_01 AC 3 ms
5,852 KB
testcase_02 AC 3 ms
5,664 KB
testcase_03 AC 3 ms
5,768 KB
testcase_04 AC 4 ms
5,704 KB
testcase_05 AC 3 ms
5,648 KB
testcase_06 AC 3 ms
5,832 KB
testcase_07 AC 3 ms
5,792 KB
testcase_08 AC 4 ms
5,652 KB
testcase_09 AC 4 ms
5,724 KB
testcase_10 AC 3 ms
5,676 KB
testcase_11 AC 3 ms
5,948 KB
testcase_12 AC 3 ms
5,764 KB
testcase_13 AC 3 ms
5,776 KB
testcase_14 AC 3 ms
5,884 KB
testcase_15 AC 3 ms
5,948 KB
testcase_16 AC 4 ms
5,664 KB
testcase_17 AC 4 ms
5,668 KB
testcase_18 AC 4 ms
5,724 KB
testcase_19 AC 4 ms
5,652 KB
testcase_20 AC 4 ms
5,780 KB
testcase_21 AC 3 ms
5,764 KB
testcase_22 AC 4 ms
5,836 KB
testcase_23 AC 4 ms
5,660 KB
testcase_24 AC 4 ms
5,728 KB
testcase_25 AC 4 ms
5,652 KB
testcase_26 AC 4 ms
5,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

struct S {
	int x, y, d;
	bool operator <(const S& s) const {
		return d > s.d;
	}
};

int dx[50];
int dy[50];
int c[50];
int dist[51][110][110];

const int INF = 1 << 25;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int gx, gy, N, F;
	cin >> gx >> gy >> N >> F;

	for(int i = 0; i < N; i++) {
		cin >> dx[i] >> dy[i] >> c[i];
	}

	fill((int*)begin(dist), (int*)end(dist), INF);
	dist[0][0][0] = 0;
	for(int i = 0; i < N; i++) {
		for(int y = 0; y <= gy; y++) {
			for(int x = 0; x <= gx; x++) {
				if(dist[i][y][x] == INF) continue;
				dist[i + 1][y][x] = min(dist[i + 1][y][x], dist[i][y][x]);
				int nx = x + dx[i], ny = y + dy[i];
				if(nx <= gx && ny <= gy) {
					dist[i + 1][ny][nx] = min(dist[i + 1][ny][nx], dist[i][y][x] + c[i]);
				}
			}
		}
	}

	int ans = INF;
	for(int y = 0; y <= gy; y++) {
		for(int x = 0; x <= gx; x++) {
			ans = min(ans, dist[N][y][x] + F * ((gx - x) + (gy - y)));

		}
	}
	cout << ans << endl;
}
0