結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー kotamanegikotamanegi
提出日時 2017-03-24 22:34:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 1,300 bytes
コンパイル時間 1,857 ms
コンパイル使用メモリ 90,628 KB
実行使用メモリ 118,508 KB
最終ジャッジ日時 2023-09-20 07:08:54
合計ジャッジ時間 2,660 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
73,804 KB
testcase_01 AC 17 ms
73,672 KB
testcase_02 AC 17 ms
73,684 KB
testcase_03 AC 17 ms
73,664 KB
testcase_04 AC 17 ms
73,856 KB
testcase_05 AC 16 ms
73,660 KB
testcase_06 AC 16 ms
73,668 KB
testcase_07 AC 16 ms
73,968 KB
testcase_08 AC 21 ms
74,404 KB
testcase_09 AC 21 ms
74,440 KB
testcase_10 AC 18 ms
74,064 KB
testcase_11 AC 17 ms
73,924 KB
testcase_12 AC 16 ms
73,664 KB
testcase_13 AC 18 ms
74,196 KB
testcase_14 AC 19 ms
74,816 KB
testcase_15 AC 17 ms
73,896 KB
testcase_16 AC 23 ms
80,084 KB
testcase_17 AC 25 ms
79,844 KB
testcase_18 AC 18 ms
74,176 KB
testcase_19 AC 18 ms
74,036 KB
testcase_20 AC 36 ms
91,280 KB
testcase_21 AC 17 ms
73,696 KB
testcase_22 AC 72 ms
117,580 KB
testcase_23 AC 74 ms
118,508 KB
testcase_24 AC 73 ms
118,168 KB
testcase_25 AC 73 ms
117,292 KB
testcase_26 AC 71 ms
115,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <random>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define LONG_INF 10000000000000000
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
long long dp[300][300][300] = {};
int main() {
	int gx, gy, n, f;
	cin >> gx >> gy >> n >> f;
	for (int i = 0;i <= 100;++i) {
		for (int q = 0;q <= 100;++q) {
			for (int j = 0;j <= 50;++j) {
				dp[i][q][j] = 100000000;
			}
		}
	}
	dp[0][0][0] = 0;
	for (int t = 0;t < n;++t) {
		long long x, y, c;
		cin >> x >> y >> c;
		for (int i = 0;i <= gx;++i) {
			for (int q = 0;q <= gy;++q) {
				dp[i + x][q + y][t + 1] = min(dp[i + x][q + y][t + 1], dp[i][q][t] + c);
				dp[i][q][t+1] = min(dp[i][q][t + 1], dp[i][q][t]);
			}
		}
	}
	long long ans = 100000000;
	for (int i = 0;i <= gx;++i) {
		for (int q = 0;q <= gy;++q) {
			ans = min(ans, (gx - i + gy - q)*f + dp[i][q][n]);
		}
	}
	cout << ans << endl;
	return 0;
}
0