結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー eiya5498513eiya5498513
提出日時 2017-03-25 00:17:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,223 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 95,796 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2023-09-20 07:14:03
合計ジャッジ時間 2,548 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,356 KB
testcase_01 AC 3 ms
5,312 KB
testcase_02 AC 3 ms
5,356 KB
testcase_03 AC 3 ms
5,368 KB
testcase_04 AC 3 ms
5,476 KB
testcase_05 AC 3 ms
5,596 KB
testcase_06 AC 3 ms
5,424 KB
testcase_07 AC 3 ms
5,456 KB
testcase_08 AC 3 ms
5,532 KB
testcase_09 AC 3 ms
5,460 KB
testcase_10 AC 3 ms
5,316 KB
testcase_11 AC 3 ms
5,496 KB
testcase_12 AC 3 ms
5,412 KB
testcase_13 AC 3 ms
5,632 KB
testcase_14 AC 3 ms
5,360 KB
testcase_15 AC 3 ms
5,316 KB
testcase_16 AC 3 ms
5,404 KB
testcase_17 AC 4 ms
5,316 KB
testcase_18 AC 3 ms
5,576 KB
testcase_19 AC 3 ms
5,360 KB
testcase_20 AC 3 ms
5,404 KB
testcase_21 AC 3 ms
5,576 KB
testcase_22 AC 3 ms
5,628 KB
testcase_23 AC 4 ms
5,580 KB
testcase_24 AC 4 ms
5,336 KB
testcase_25 AC 3 ms
5,412 KB
testcase_26 AC 3 ms
5,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}

int Gx, Gy;
int32_t N,F;
int X[100];
int Y[100];
int C[100];
constexpr int INF = 1000000000;
int32_t DP[101][101][51];
int32_t func(int x, int y, int i)
{
	if (x > Gx || y > Gy) { return INF; }
	if (i == N) {
		return F*(Gx - x + Gy - y);
	}
	if (DP[x][y][i] != -1) {
		return DP[x][y][i];
	}
	return DP[x][y][i] =
		std::min(
			func(x+X[i],y + Y[i],i+1) + C[i],
			func(x, y, i + 1)
		)
		;
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	fill_all(DP, -1);
	in >> Gx>>Gy>>N>>F;
	for (size_t i = 0; i < N; i++)
	{
		in >> X[i] >> Y[i] >> C[i];
	}

	out << func(0, 0, 0) << endl;

	return 0;
}
#endif
0