結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー Nafmo2Nafmo2
提出日時 2017-03-26 18:36:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,304 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 75,756 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 06:31:52
合計ジャッジ時間 4,276 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 4
other AC * 1 RE * 22
権限があれば一括ダウンロードができます

ソースコード

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