哪有这么复杂
int main(){
	int m(0), n(0), a(0), b(0), c(0), d(0), x(0), y(0), z(0);
	cin >> n >> m;//彩笔、白笔
	cin >> a >> b >> c >> d;//混彩、混白、纯白、纯彩
	cin >> x >> y >> z;//混、白、彩
	int i = 0;//混搭盒数
	int res(0);
	while (i * a <= n && i * b <= m){
		int temp(0);
		temp += i * x;
		temp += (n - i * a) / d * z;
		temp += (m - i * b) / c * y;
		if (temp > res){
			res = temp;
		}
		i++;
	}
	cout << res;
	return 0;
}