結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー okchan08okchan08
提出日時 2018-04-06 13:30:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 987 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 66,604 KB
実行使用メモリ 5,532 KB
最終ジャッジ日時 2023-09-08 17:58:37
合計ジャッジ時間 1,981 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

struct crystal{
    int x,y,c;
    crystal(){};
    crystal(int x, int y, int c): x(x), y(y), c(c){};
};

int main(){
    int gx,gy,N,F;
    cin >> gx >> gy >> N >> F;
    vector<crystal> vec(N);
    for(int i=0;i<N;i++){
        int x,y,c;
        cin >> x >> y >> c;
        vec[i] = crystal(x,y,c);
    }

    vector<vector<vector<int> > > dp(N+1, vector<vector<int> >(gx+1, vector<int>(gy+1)));
    for(int i=0;i<=gx;i++){
        for(int j=0;j<=gy;j++){
            dp[0][i][j] = (i+j)*F;
        }
    }
    for(int t=0;t<N;t++){
        for(int i=0;i<=gx;i++){
            for(int j=0;j<=gy;j++){
                if(i-vec[t].x >= 0 && j-vec[t].y >= 0){
                    dp[t+1][i][j] = min(dp[t][i][j], dp[t][i-vec[t].x][j-vec[t].y] + vec[t].c);
                }else{
                    dp[t+1][i][j] = dp[t][i][j];
                }
            }
        }
    }
    cout << dp[N][gx][gy] << endl;
    return 0;
}
0