#include #include #include using namespace std; #define INF 1930000000 const int MAX_N = 50; const int MAX_X = 100; const int MAX_Y = 100; int dp[MAX_X+1][MAX_Y+1]; int main(){ int gx,gy,N,F; cin >> gx >> gy >> N >> F; int x,y,c; for(int j = 0; j < gx+1; j++){ for(int k = 0; k < gy+1; k++){ dp[j][k] = F*(gx+gy);//初期化 } } for(int t = 0; t < N; t++){ cin >> x >> y >> c; for(int i = 0; i < gx+1; i++){ for(int j = 0; j < gy+1; j++){ if(i - x >= 0 && j - y >= 0){ dp[i][j] = min(dp[i][j],dp[i-x][j-y]+c); } } } } cout << dp[gx][gy] <