結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 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) {
        rep(y, 103) rep(x, 103) {
            if (y-Y[i] < 0 || x-X[i] < 0) continue;
            dp[y][x] = min(dp[y][x], dp[y-Y[i]][x-X[i]] + C[i]);
        }
    }

    rep(y, 103) rep(x, 103) {
        dp[y+1][x] = min(dp[y+1][x], dp[y][x]+F);
        dp[y][x+1] = min(dp[y][x+1], dp[y][x]+F);
    }

    cout << dp[gy][gx] << endl;
}
0