結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー ikdikd
提出日時 2017-03-24 23:27:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 938 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 53,616 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-20 03:53:41
合計ジャッジ時間 1,713 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>

using namespace std;
#define repeat(i, n) for(int i=0; i<(n); i++)
int memo[101][101];
const int inf=1e8;

int main(){

   int gx, gy, N, F;
   cin>> gx>> gy>> N>> F;
   int dx[N], dy[N], c[N];
   for(int i=0; i<N; i++) cin>> dx[i]>> dy[i]>> c[i];

   repeat(x, 101){
      repeat(y, 101){
         if(x==0&&y==0) memo[x][y]=0;
         else memo[x][y]=inf;
      }
   }

   repeat(i, N){
      if(c[i]>(dx[i]+dy[i])*F) continue;
      repeat(x, gx+1){
         repeat(y, gy+1){
            if(memo[x][y]==inf) continue;
            if(x+dx[i]>gx||y+dy[i]>gy) continue;
            memo[x+dx[i]][y+dy[i]]
            =min(memo[x+dx[i]][y+dy[i]], memo[x][y]+c[i]);
         }
      }
   }

   int C=inf;
   repeat(x, gx+1){
      repeat(y, gy+1){
         if(memo[x][y]==inf) continue;
         int _c=F*((gx-x)+(gy-y));
         _c+=memo[x][y];
         C=min(C, _c);
      }
   }

   cout<< C<< endl;

   return 0;
}
0