#include <algorithm>
#include <iostream>
using namespace std;
int n, m, a, b, c, d, x, y, z;
int main()
{
cin >> n >> m >> a >> b >> c >> d >> x >> y >> z;
int max_ = INT_MIN;
int left = n / c, right = m / d;
for (int i = 0; i <= left; ++i) {
for (int j = 0; j <= right; ++j) {
int k = min((n - i * c) / a, (m - j * d) / b);
max_ = max(max_, k * x + i * z + j * y);
}
}
cout << max_ << endl;
return 0;
}
贴个简单的