#include #include using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define all(x) begin(x), end(x) template bool chmin(T& x, T y) { return x > y ? (x = y, true) : false; } template bool chmax(T& x, T y) { return x < y ? (x = y, true) : false; } void solve() { ll r, p, q; cin >> r >> p >> q; ll a, b, c, d; cin >> a >> b >> c >> d; ll up = 1e9 + 1; ll dw = 0; while (up - dw > 1) { ll md = (up + dw) / 2; ll dd = d; if (a > md) dd += a - md; if (b > md) dd += b - md; if (c > md) dd += c - md; ll nc = max(0ll, md - a) + max(0ll, md - b) + max(0ll, md - c); if (dd >= nc && r >= md * p + nc * q) dw = md; else up = md; } cout << dw << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); int t = 1; // cin >> t; while (t--) solve(); }