結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー 👑 Nafmo2Nafmo2
提出日時 2017-03-26 18:36:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,304 bytes
コンパイル時間 581 ms
コンパイル使用メモリ 75,060 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 11:05:24
合計ジャッジ時間 4,855 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 1 ms
4,376 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
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<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X;}
#define TF(f) {f;}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1000000;
    int dp[52][110][110];
    bool vis[52][110][110];
    int X[100],Y[100],c[100];
    int N,F,Gx,Gy,ans;
int dfs(int n,int x,int y){
    if(vis[n][x][y]){
        return dp[n][x][y];
    }else vis[n][x][y]=true;

    if(n<0){dp[n][x][y]=(x+y)*F;}
    else if(x>=X[n]&&y>=Y[n])
    {
        dp[n][x][y]=min(dfs(n-1,x-X[n],y-Y[n])+c[n],dfs(n-1,x,y));
        /*DEB(n)DEB(x)DEB(y)END
        DEB(dfs(n-1,x-X[n],y-Y[n])+c[n])DEB(dfs(n-1,x,y))END END*/
    }
    else {dp[n][x][y]=dfs(n-1,x,y);/*DEB(dfs(n-1,x,y))END*/}

    return dp[n][x][y];

}
int main() {
    ios_base::sync_with_stdio(false);
    cin>>Gx>>Gy>>N>>F;
    REP(i,N)cin>>X[i]>>Y[i]>>c[i];
    cout<<dfs(N-1,Gx,Gy)<<endl;

    return 0;
}
0