結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー |
![]() |
提出日時 | 2019-07-19 07:53:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 560 bytes |
コンパイル時間 | 613 ms |
コンパイル使用メモリ | 75,276 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 23:56:02 |
合計ジャッジ時間 | 1,455 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int gx, gy, n, f; cin >> gx >> gy >> n >> f; vector<vector<int>> dp(gx + 1, vector<int>(gy + 1)); for (int i = 0; i <= gx; i++) for (int j = 0; j <= gy; j++) { dp[i][j] = (i + j) * f; } while (n--) { int a, b, c; cin >> a >> b >> c; for (int i = gx; i >= a; i--) for (int j = gy; j >= b; j--) { dp[i][j] = min(dp[i][j], dp[i - a][j - b] + c); } } cout << dp[gx][gy] << endl; return 0; }