結果
| 問題 | No.496 ワープクリスタル (給料日前編) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-24 22:26:51 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| + 637µs | |
| コード長 | 730 bytes |
| 記録 | |
| コンパイル時間 | 364 ms |
| コンパイル使用メモリ | 91,416 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-08-08 22:08:08 |
| 合計ジャッジ時間 | 2,009 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
using namespace std;
int dp[101][101];
int main() {
for (int i = 0; i < 101; i++) {
for (int j = 0; j < 101; j++) {
dp[i][j] = 1e9;
}
}
int gx, gy, n, f;
cin >> gx >> gy >> n >> f;
dp[0][0] = 0;
while (n--) {
int x, y, c;
cin >> x >> y >> c;
for (int i = gx - x; i >= 0; i--) {
for (int j = gy - y; j >= 0; j--) {
dp[i + x][j + y] = min(dp[i + x][j + y], dp[i][j] + c);
}
}
}
int ans = 1e9;
for (int i = 0; i <= gx; i++) {
for (int j = 0; j <= gy; j++) {
ans = min(ans, dp[i][j] + f * (abs(gx - i) + abs(gy - j)));
}
}
cout << ans << endl;
}