結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー nenuonnenuon
提出日時 2017-06-23 17:50:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,165 bytes
コンパイル時間 979 ms
コンパイル使用メモリ 91,572 KB
実行使用メモリ 15,668 KB
最終ジャッジ日時 2024-04-14 07:41:58
合計ジャッジ時間 4,750 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 18 ms
15,512 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 365 ms
15,412 KB
testcase_09 AC 362 ms
15,624 KB
testcase_10 AC 5 ms
6,940 KB
testcase_11 AC 5 ms
6,940 KB
testcase_12 AC 25 ms
6,940 KB
testcase_13 AC 34 ms
6,940 KB
testcase_14 AC 63 ms
8,020 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 64 ms
9,660 KB
testcase_19 WA -
testcase_20 AC 42 ms
10,148 KB
testcase_21 AC 20 ms
6,940 KB
testcase_22 WA -
testcase_23 AC 302 ms
15,532 KB
testcase_24 AC 297 ms
15,540 KB
testcase_25 AC 311 ms
15,468 KB
testcase_26 AC 308 ms
15,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
  int gy,gx,n,f;
  cin>>gx>>gy>>n>>f;
  int x[n],y[n],c[n];
  FOR(i,0,n){
    cin >> x[i] >> y[i] >> c[i];
  }
  int dp[301][gy+1][gx+1];
  FOR(i,0,301){
    FOR(j,0,gy+1){
      FOR(k,0,gx+1){
        dp[i][j][k] = 999999;
      }
    }
  }
  dp[0][0][0] = 0;
  FOR(i,0,300){
    FOR(j,0,gy+1){
      FOR(k,0,gx+1){
        if(dp[i][j][k] == 999999) continue;
        dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
        if(j+1 <= gy) dp[i+1][j+1][k] = min(dp[i+1][j+1][k], dp[i][j][k] + f);
        if(k+1 <= gx) dp[i+1][j][k+1] = min(dp[i+1][j][k+1], dp[i][j][k] + f);
        FOR(l,0,n){
          int nx = k + x[l], ny = j + y[l];
          if(nx > gx || ny > gy) continue;
          dp[i+1][ny][nx] = min(dp[i+1][ny][nx], dp[i][j][k] + c[l]);
        }
      }
    }
  }
  cout << dp[300][gy][gx] << endl;
  return 0;
}
0