結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー |
![]() |
提出日時 | 2017-07-12 02:22:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 620 bytes |
コンパイル時間 | 1,810 ms |
コンパイル使用メモリ | 168,876 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-07 15:14:21 |
合計ジャッジ時間 | 2,510 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 6 WA * 17 |
ソースコード
#include <bits/stdc++.h>#define REP(i,n,N) for(int i=(n);i<(int) N;i++)#define p(s) cout<<(s)<<endlusing namespace std;const int inf=1e9;int dp[110][110];int x[55],y[55],c[55];int main(){int gx,gy,N,F;cin>>gx>>gy>>N>>F;REP(i,0,N) cin>>x[i]>>y[i]>>c[i];REP(i,0,gx+1) REP(j,0,gy+1) dp[i][j]=inf;dp[0][0]=0;REP(i,0,gx) REP(j,0,gy) REP(k,0,N) {if(i+x[k]>gx||i+y[k]>gy) continue;dp[i+x[k]][j+y[k]]=min(dp[i+x[k]][j+y[k]],dp[i][j]+c[k]);}REP(i,0,gx+1) REP(j,0,gy+1){if(j>0)dp[i][j]=min(dp[i][j],dp[i][j-1]+F);else if(i>0) dp[i][j]=min(dp[i][j],dp[i-1][j]+F);}p(dp[gx][gy]);return 0;}