結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー oxyshoweroxyshower
提出日時 2019-12-01 20:02:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,061 bytes
コンパイル時間 1,572 ms
コンパイル使用メモリ 169,852 KB
実行使用メモリ 8,060 KB
最終ジャッジ日時 2024-05-01 12:03:47
合計ジャッジ時間 2,244 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,012 KB
testcase_01 AC 2 ms
7,956 KB
testcase_02 AC 3 ms
8,028 KB
testcase_03 AC 3 ms
7,956 KB
testcase_04 AC 2 ms
8,060 KB
testcase_05 AC 3 ms
7,812 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 6 ms
7,920 KB
testcase_09 AC 5 ms
8,032 KB
testcase_10 AC 3 ms
8,008 KB
testcase_11 AC 3 ms
7,864 KB
testcase_12 AC 3 ms
7,964 KB
testcase_13 AC 3 ms
7,972 KB
testcase_14 AC 3 ms
8,024 KB
testcase_15 AC 3 ms
8,016 KB
testcase_16 AC 3 ms
7,980 KB
testcase_17 AC 4 ms
7,956 KB
testcase_18 AC 4 ms
7,944 KB
testcase_19 AC 4 ms
8,008 KB
testcase_20 AC 3 ms
7,940 KB
testcase_21 AC 3 ms
7,816 KB
testcase_22 AC 5 ms
7,968 KB
testcase_23 AC 5 ms
7,964 KB
testcase_24 AC 6 ms
7,984 KB
testcase_25 AC 5 ms
7,804 KB
testcase_26 AC 5 ms
8,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int Gx, Gy, N, F; cin >> Gx >> Gy >> N >> F;
  if(N == 0){
    cout << F * (Gx + Gy) << endl;
    return 0;
  }
  static int dp[111][111][51];
  fill(dp[0][0], dp[101][101] + 50, INF);
  dp[0][0][0] = 0;
  for(int i = 0; i < N; i++){
    int x, y, c; cin >> x >> y >> c;
    for(int j = 0; j <= Gx; j++){
      for(int k = 0; k <= Gy; k++){
        dp[j][k][i+1] = min(dp[j][k][i+1], dp[j][k][i]);
        if(j + x <= Gx && k + y <= Gy){
          dp[j + x][k + y][i+1] = min(dp[j + x][k + y][i+1], dp[j][k][i] + c);
        }
      }
    }
    for(int j = 0; j <= Gx; j++){
      for(int k = 0; k <= Gy; k++){
        if(j + 1 <= Gx){
          dp[j + 1][k][i+1] = min(dp[j + 1][k][i+1], dp[j][k][i+1] + F);
        }
        if(k + 1 <= Gy){
          dp[j][k + 1][i+1] = min(dp[j][k + 1][i+1], dp[j][k][i+1] + F);
        }
      }
    }
  }
  cout << dp[Gx][Gy][N] << endl;

  return 0;
}
0