結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー fiordfiord
提出日時 2017-03-25 06:58:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 791 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 81,948 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 08:23:20
合計ジャッジ時間 1,845 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
using namespace std;
#define fst first
#define scn second
int dp[101][101];
int 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];
	for(int i=0;i<=100;i++)	for(int j=0;j<=100;j++)	dp[i][j]=1e9;
	dp[0][0]=0;
	set<pair<int,int>> pos;
	pos.insert(make_pair(0,0));
	for(int i=0;i<n;i++){
		for(auto it:pos){
			int ny=it.fst+y[i],nx=it.scn+x[i];
			if(ny<=gy&&nx<=gx){
				dp[ny][nx]=min(dp[ny][nx],dp[it.fst][it.scn]+c[i]);
				pos.insert(make_pair(ny,nx));
			}
		}
	}
	int ret=1e9;
	for(int i=0;i<=gy;i++){
		for(int j=0;j<=gx;j++){
			int cost=dp[i][j]+f*((gy+gx)-(i+j));
			ret=min(ret,cost);
		}
	}
	cout<<ret<<endl;
	return 0;
}
0