結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー Kiona1018Kiona1018
提出日時 2019-09-15 19:10:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 991 bytes
コンパイル時間 1,542 ms
コンパイル使用メモリ 169,468 KB
実行使用メモリ 11,256 KB
最終ジャッジ日時 2023-09-21 04:10:49
合計ジャッジ時間 5,783 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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);
    }

    int dp[n+1][2*gx][2*gy];
    rep(k, 0, n+1) rep(i, 0, 3*gx) rep(j, 0, 3*gy) 
        dp[k][i][j] = (i + j) * f;
    
    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]
                );
                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