zoj 1013

// C++Exercise.cpp : 定义控制台应用程序的入口点。
//

#include<iostream>
#include<string>
#include<cstring>
#include<stack>
#include<map>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<cstdio>
#define max_n 510
using namespace std;

int record[2][max_n][max_n];
int n;
int helm[3],armor[3],boot[3];
int c1, c2, c3, d4;

int main(){
	int Case = 0;
	while (cin >> n&&n){
		Case++;
		cin >> helm[0] >> helm[1] >> helm[2];
		cin >> armor[0] >> armor[1] >> armor[2];
		cin >> boot[0] >> boot[1] >> boot[2];
		cin >> c1 >> c2 >> c3 >> d4;
		int maxHelm = 0, maxArmor = 0;
		int x, y;
		int cur = 1;
		int pre = 0;
		memset(record, 0, sizeof(record));
		for (int i = 0; i < n; i++){
			cin >> x >> y;
			int temph = min(x/helm[0],y/helm[1]);
			memset(record[cur],-1,sizeof(record[cur]));
			for (int a = 0; a <= temph; a++){
				int tempa = min((x-helm[0]*a)/armor[0],(y-helm[1]*a)/armor[1]);
				for (int b = 0; b <= tempa; b++){
					int boo = min((x-helm[0]*a-armor[0]*b)/boot[0],(y-helm[1]*a-armor[1]*b)/boot[1]);
					for (int ai = 0; ai <= maxHelm; ai++){
						for (int bi = 0; bi <= maxArmor; bi++){
							if (record[pre][ai][bi] != -1){
								record[cur][ai + a][bi + b] = max(record[cur][ai+a][bi+b],record[pre][ai][bi]+boo);
							}
						}
					}
				}
			}
			maxHelm += temph;
			maxArmor += min(x/armor[0],y/armor[1]);
			swap(cur,pre);
		}
		int res = 0;
		for (int i = 0; i <= maxHelm; i++){
			for (int j = 0; j <= maxArmor; j++){
				if (record[pre][i][j]>=0){
					int combine = min(min(i/c1,j/c2),record[pre][i][j]/c3);
					res = max(res,combine*d4+(i-combine*c1)*helm[2]+(j-combine*c2)*armor[2]+
						(record[pre][i][j]-combine*c3)*boot[2]);
				}
			}
		}
		if (Case > 1) cout << endl;
		cout << "Case " << Case << ": " << res << endl;
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值