結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー kotamanegikotamanegi
提出日時 2017-03-24 22:33:28
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,300 bytes
コンパイル時間 1,163 ms
コンパイル使用メモリ 92,252 KB
実行使用メモリ 34,008 KB
最終ジャッジ日時 2023-09-20 07:07:43
合計ジャッジ時間 2,886 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
18,768 KB
testcase_01 AC 5 ms
18,764 KB
testcase_02 AC 5 ms
19,008 KB
testcase_03 AC 5 ms
18,800 KB
testcase_04 AC 6 ms
18,716 KB
testcase_05 AC 5 ms
18,840 KB
testcase_06 AC 6 ms
18,880 KB
testcase_07 AC 5 ms
18,764 KB
testcase_08 AC 9 ms
18,796 KB
testcase_09 AC 8 ms
19,052 KB
testcase_10 AC 6 ms
19,140 KB
testcase_11 AC 6 ms
18,808 KB
testcase_12 AC 6 ms
18,808 KB
testcase_13 AC 6 ms
18,788 KB
testcase_14 AC 6 ms
19,268 KB
testcase_15 AC 6 ms
19,064 KB
testcase_16 AC 9 ms
20,944 KB
testcase_17 AC 9 ms
20,760 KB
testcase_18 AC 7 ms
19,100 KB
testcase_19 AC 8 ms
19,520 KB
testcase_20 AC 13 ms
24,660 KB
testcase_21 AC 6 ms
18,820 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 AC 29 ms
34,008 KB
testcase_25 RE -
testcase_26 AC 28 ms
33,156 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[200][200][100] = {};
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