結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー beetbeet
提出日時 2018-12-06 16:20:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 1,232 bytes
コンパイル時間 2,346 ms
コンパイル使用メモリ 203,176 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 02:46:55
合計ジャッジ時間 4,246 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 3 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 7 ms
4,348 KB
testcase_09 AC 7 ms
4,352 KB
testcase_10 AC 7 ms
4,352 KB
testcase_11 AC 6 ms
4,348 KB
testcase_12 AC 7 ms
4,348 KB
testcase_13 AC 5 ms
4,348 KB
testcase_14 AC 4 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 5 ms
4,352 KB
testcase_18 AC 3 ms
4,352 KB
testcase_19 AC 4 ms
4,352 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 4 ms
4,352 KB
testcase_22 AC 6 ms
4,348 KB
testcase_23 AC 6 ms
4,348 KB
testcase_24 AC 6 ms
4,352 KB
testcase_25 AC 6 ms
4,352 KB
testcase_26 AC 6 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//INSERT ABOVE HERE
signed 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];

  const Int INF = 1e15;
  auto dp=make_v<Int>(200,200);
  fill_v(dp,INF);
  dp[0][0]=0;
  for(Int i=0;i<n;i++)
    for(Int a=199;a>=0;a--)
      for(Int b=199;b>=0;b--)
        if(a+y[i]<200&&b+x[i]<200)
          chmin(dp[a+y[i]][b+x[i]],dp[a][b]+c[i]);

  Int ans=INF;
  for(Int i=0;i<=gy;i++)
    for(Int j=0;j<=gx;j++)
      chmin(ans,dp[i][j]+(gy-i+gx-j)*f);
  
  cout<<ans<<endl;
  return 0;
}
0