#if __has_include() #include #else #include #include #endif using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define printYesNo(is_ok) puts(is_ok ? "Yes" : "No") #define SORT(v) sort(v.begin(), v.end()) #define RSORT(v) sort(v.rbegin(), v.rend()) #define REVERSE(v) reverse(v.begin(), v.end()) template void printVector(const Container &v, char delimiter = ' ') { for (auto itr = v.begin(); itr != v.end(); itr++) { if (itr != v.begin()) { cout << delimiter; } cout << *itr; } cout << endl; } template void printlnVector(const Container &v) { printVector(v, '\n'); } template enable_if_t, T> bin_search(T ok, T ng, function check) { while (max(ok, ng) - min(ok, ng) > 1) { T mid = midpoint(ok, ng); (check(mid) ? ok : ng) = mid; } return ok; } void solve() { long long R, P, Q, D; vector ABC(3); cin >> R >> P >> Q >> ABC[0] >> ABC[1] >> ABC[2] >> D; RSORT(ABC); // x人作る auto check = [&](long long x) -> bool { if (R < P * x) { return false; } long long r = R - P * x; long long d = D; rep(i, 3) { long long use = min(x, ABC[i]); if (use != x) { d -= x - use; if (d < 0) { return false; } r -= (x - use) * Q; } else { d += ABC[i] - use; } } return 0 <= r; }; long long ans = bin_search(0, 2 * (ABC[0] + ABC[1] + ABC[2] + D), check); cout << ans << endl; } int main() { int T = 1; // cin >> T; while (T--) { solve(); } return 0; }