結果
| 問題 |
No.496 ワープクリスタル (給料日前編)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-29 18:36:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 886 bytes |
| コンパイル時間 | 675 ms |
| コンパイル使用メモリ | 75,272 KB |
| 最終ジャッジ日時 | 2025-01-10 16:16:00 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
#include <iostream>
#include <vector>
template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
constexpr int INF = 1 << 30;
void solve() {
int h, w, n, f;
std::cin >> h >> w >> n >> f;
auto cost = vec(h + 1, vec(w + 1, INF));
cost[0][0] = 0;
while (n--) {
int dx, dy, c;
std::cin >> dx >> dy >> c;
for (int x = h; x >= dx; --x) {
for (int y = w; y >= dy; --y) {
cost[x][y] = std::min(cost[x][y], cost[x - dx][y - dy] + c);
}
}
}
int ans = INF;
for (int x = 0; x <= h; ++x) {
for (int y = 0; y <= w; ++y) {
ans = std::min(ans, cost[x][y] + (h - x + w - y) * f);
}
}
std::cout << ans << "\n";
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
solve();
return 0;
}