結果
問題 |
No.496 ワープクリスタル (給料日前編)
|
ユーザー |
![]() |
提出日時 | 2019-04-30 19:07:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,240 bytes |
コンパイル時間 | 1,090 ms |
コンパイル使用メモリ | 77,228 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-30 21:52:18 |
合計ジャッジ時間 | 2,129 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 WA * 6 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <map> #include <string> #include <queue> #include <stack> #include <math.h> #include <set> #include <cstdio> #define ALL(obj) (obj).begin(),(obj).end() #define RALL(obj) (obj).rbegin(),(obj).rend() #define P pair<int, int> #define MOD 1000000007 #define INF 1012345678 #define NINF (-2147483647-1) #define LLINF 9223372036854775807 using ll = long long; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int gx, gy, N, F; cin >> gx >> gy >> N >> F; vector<vector<int>> dp(gx + 1, vector<int>(gy + 1,INF)); dp[0][0] = 0; for (int i = 0; i < N; i++) { int x, y, cost; cin >> x >> y >> cost; for (int j = 0; j <= gx; j++) { for (int k = 0; k <= gy; k++) { if (j - x >= 0 && k - y >= 0) { dp[j][k] = min(dp[j][k], dp[j - x][k - y] + cost); } } } } int ans = INF; for (int i = 0; i <= gx; i++) { for (int j = 0; j <= gy; j++) { ans = min(ans, dp[i][j] + (gx - i + gy - j) * F); } } cout << ans << endl; getchar(); getchar(); }