結果
| 問題 |
No.496 ワープクリスタル (給料日前編)
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-04-05 13:35:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 902 bytes |
| コンパイル時間 | 2,187 ms |
| コンパイル使用メモリ | 199,064 KB |
| 最終ジャッジ日時 | 2025-01-09 14:12:43 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using lubl=long double;
void cmn(lint&x,lint y){if(x>y)x=y;}
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
lint inf=std::numeric_limits<lint>::max();
lint h,w,n,f;std::cin>>h>>w>>n>>f;
std::vector<std::vector<lint>>dp(h+1,std::vector<lint>(w+1,inf));
dp.at(0).at(0)=0;
while(n--){
lint x,y,c;std::cin>>x>>y>>c;
for(lint i=h-x;i>=0;i--){
for(lint j=w-y;j>=0;j--){
if(dp.at(i).at(j)==inf)continue;
cmn(dp.at(i+x).at(j+y),dp.at(i).at(j)+c);
}}
}
lint ans=inf;
for(lint i=0;i<=h;i++){
for(lint j=0;j<=w;j++){
if(dp.at(i).at(j)==inf)continue;
cmn(ans,dp.at(i).at(j)+f*(h-i+w-j));
}}
std::cout<<ans<<'\n';
}
ngtkana