結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー |
|
提出日時 | 2017-03-31 04:52:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 850 bytes |
コンパイル時間 | 1,492 ms |
コンパイル使用メモリ | 168,936 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-07 03:38:35 |
合計ジャッジ時間 | 2,442 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)#define all(x) (x).begin(),(x).end()#define pb push_back#define fi first#define se secondconst int INF=123456789;int dp[101][101];int main(){int Gx,Gy,N,F;cin >>Gx >>Gy >>N >>F;fill(dp[0],dp[101],INF);dp[0][0]=0;while(N--){int x,y,c;cin >>x >>y >>c;for(int i=Gy; i>=0; --i)for(int j=Gx; j>=0; --j){int nx=j+x, ny=i+y;if(ny>Gy || nx>Gx) continue;dp[ny][nx] = min(dp[ny][nx], dp[i][j]+c);}}int ans = INF;rep(i,Gy+1)rep(j,Gx+1) ans = min(ans, dp[i][j]+F*(Gy-i+Gx-j));cout << ans << endl;return 0;}