結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー daleksprinterdaleksprinter
提出日時 2018-09-14 00:00:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 983 bytes
コンパイル時間 1,567 ms
コンパイル使用メモリ 166,072 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 20:02:14
合計ジャッジ時間 2,858 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define int long long
const int inf = 100100100100100;
const int mod = 1000000007;

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int x,y, n, f;
    cin >> x >> y >> n >> f;

    int dp[y+1][x+1];
    dp[0][0] = 0;
    rep(i,1,y+1){
        dp[i][0] = dp[i-1][0] + f;
    }
    rep(i,0,y+1){
        rep(j,1,x+1){
            dp[i][j] = dp[i][j-1] + f;
        }
    }

    int crystals[n][3];


    rep(i,0,n){
        rep(j,0,3){
            cin >> crystals[i][j];
        }
    }


    rep(k,0,n){
        for(int i = y; i > -1; i--){
            for(int j = x; j > -1; j--){
                int dx = j-crystals[k][0];
                int dy = i-crystals[k][1];
                if(-1 < dx && -1 < dy){
                    dp[i][j] = min(dp[i][j], dp[dy][dx] + crystals[k][2]);
                }
          } 
        }
    }

    cout << dp[y][x] << endl;

}

0