結果
| 問題 |
No.496 ワープクリスタル (給料日前編)
|
| コンテスト | |
| ユーザー |
dnish
|
| 提出日時 | 2018-06-19 09:45:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 1,038 bytes |
| コンパイル時間 | 1,614 ms |
| コンパイル使用メモリ | 169,772 KB |
| 実行使用メモリ | 6,016 KB |
| 最終ジャッジ日時 | 2024-06-30 17:10:57 |
| 合計ジャッジ時間 | 2,610 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
#include "bits/stdc++.h"
#define REP(i,n,N) for(int i=(n); i<(N); i++)
#define RREP(i,n,N) for(int i=(N-1); i>=n; i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const int inf=1e9;
int gx, gy, N, F;
int dp[52][110][110];
vector<int> x(110),y(110),c(110);
int main() {
cin>>gx>>gy>>N>>F;
REP(i,0,N){
cin>>x[i]>>y[i]>>c[i];
}
REP(i,0,N+1) REP(j,0,gy+1) REP(k,0,gx+1) dp[i][j][k]=inf;
dp[0][0][0]=0;
REP(i,0,N){
REP(Y,0,gy+1){
REP(X,0,gx+1){
dp[i+1][Y][X]=min(dp[i+1][Y][X], dp[i][Y][X]);
if(Y+y[i]<=gy&&X+x[i]<=gx) dp[i+1][Y+y[i]][X+x[i]] = min(dp[i+1][Y+y[i]][X+x[i]], dp[i][Y][X]+c[i]);
}
}
}
int ans=inf;
REP(i,0,gy+1){
REP(j,0,gx+1){
ans=min(ans,dp[N][i][j]+F*((gy-i)+(gx-j)));
}
}
p(ans);
return 0;
}
dnish