結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー izryt(趣味)izryt(趣味)
提出日時 2017-04-04 23:43:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 878 bytes
コンパイル時間 1,925 ms
コンパイル使用メモリ 164,476 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 17:20:18
合計ジャッジ時間 2,627 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define rep(i, x) for (int i = 0; i < x; ++i)
#define rrep(i, x) for (int i = x-1; i >= 0; --i)

const int inf = 1e9;

int X[55], Y[55], C[55];

int dp[105][105];

int main()
{
    int gx, gy; cin >> gx >> gy;
    int N, F; cin >> N >> F;
    rep(i, N) {
        cin >> X[i] >> Y[i] >> C[i];
    }

    rep(i, 105) rep(j, 105) dp[i][j] = inf;
    dp[0][0] = 0;

    rep(i, N) {
        rrep(y, 103) rrep(x, 103) {
            if (y-Y[i] < 0 || x-X[i] < 0) continue;
            if (dp[y-Y[i]][x-X[i]] == inf) continue;
            dp[y][x] = min(dp[y][x], dp[y-Y[i]][x-X[i]] + C[i]);
        }
    }

    int ans = inf;

    rep(y, 103) rep(x, 103) {
        if (dp[y][x] == inf) continue;
        if (gy - y < 0 || gx - x < 0) continue;
        ans = min(ans, dp[y][x] + (gy - y + gx - x) * F);
    }

    cout << ans << endl;
}
0