結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー |
|
提出日時 | 2017-03-26 18:37:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,297 bytes |
コンパイル時間 | 567 ms |
コンパイル使用メモリ | 75,744 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-06 06:31:54 |
合計ジャッジ時間 | 1,365 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
#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 {}#endifconst 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(n<0){return (x+y)*F; }if(vis[n][x][y]){return dp[n][x][y];}else vis[n][x][y]=true;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)ENDDEB(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;}