結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー Kiona1018Kiona1018
提出日時 2019-09-15 19:16:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,228 bytes
コンパイル時間 1,519 ms
コンパイル使用メモリ 168,124 KB
実行使用メモリ 11,584 KB
最終ジャッジ日時 2023-09-21 04:11:05
合計ジャッジ時間 2,817 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
struct crystal{int x, y, c;};

int main()
{
    int gx, gy, n, f;
    cin >> gx >> gy >> n >> f;

    vector<crystal> cry;
    rep(i, 0, n)
    {
        crystal c;
        cin >> c.x >> c.y >> c.c;
        
        cry.push_back(c);
        cout << "***" << endl;
    }
    // cout <<"*LJ:J" << endl;

    int dp[n+1][2*gx][2*gy];
    // int dp[n+1][30][30];
    // cout << n + 1 << 3 * gx << 3*gy << endl;
    rep(k, 0, n+1) rep(i, 0, 2*gx) rep(j, 0, 2*gy) 
        dp[k][i][j] = (i + j) * f;

    // cout << "***********" << endl;
    rep(k, 0, n)
    {
        crystal c = cry[k];
        rep(i, 0, gx + 1)
            rep(j, 0, gy + 1)
            {
                dp[k+1][i][j] = min(
                    dp[k+1][i][j],
                    dp[k][i][j]
                );
                if (i+c.x <= gx and j+c.y <= gy)
                    dp[k+1][i+c.x][j+c.y] = min(
                        dp[k][i+c.x][j+c.y],
                        dp[k][i][j] + c.c
                    );
            }
    }

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