結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー |
![]() |
提出日時 | 2020-04-05 13:48:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 1,040 bytes |
コンパイル時間 | 2,001 ms |
コンパイル使用メモリ | 197,712 KB |
最終ジャッジ日時 | 2025-01-09 14:13:02 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;} #define ENABLE_DEBUG 1 #ifdef NGTKANA #include<debug.hpp> #else #define DEBUG(...){} #endif 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); }} DEBUG(matrix_style(skipinf(dp,inf))); } 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'; }