結果
| 問題 | No.496 ワープクリスタル (給料日前編) |
| コンテスト | |
| ユーザー |
fiord
|
| 提出日時 | 2017-03-25 06:58:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 791 bytes |
| 記録 | |
| コンパイル時間 | 679 ms |
| コンパイル使用メモリ | 81,560 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-06 04:08:59 |
| 合計ジャッジ時間 | 1,319 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 WA * 6 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
using namespace std;
#define fst first
#define scn second
int dp[101][101];
int main(){
int gx,gy,n,f; cin>>gx>>gy>>n>>f;
vector<int> x(n),y(n),c(n);
for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>c[i];
for(int i=0;i<=100;i++) for(int j=0;j<=100;j++) dp[i][j]=1e9;
dp[0][0]=0;
set<pair<int,int>> pos;
pos.insert(make_pair(0,0));
for(int i=0;i<n;i++){
for(auto it:pos){
int ny=it.fst+y[i],nx=it.scn+x[i];
if(ny<=gy&&nx<=gx){
dp[ny][nx]=min(dp[ny][nx],dp[it.fst][it.scn]+c[i]);
pos.insert(make_pair(ny,nx));
}
}
}
int ret=1e9;
for(int i=0;i<=gy;i++){
for(int j=0;j<=gx;j++){
int cost=dp[i][j]+f*((gy+gx)-(i+j));
ret=min(ret,cost);
}
}
cout<<ret<<endl;
return 0;
}
fiord