#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int32_t n, d; cin >> n >> d; vector xs(n), vs(n); for (auto &&x : xs) { cin >> x; } for (auto &&v : vs) { cin >> v; } int32_t left = 0, right = d; while (left + 1 < right) { int64_t t = (left + right) / 2; int64_t s = 0; for (auto i = 0; i < n; ++i) { auto d = vs[i] * t; if (s > numeric_limits::max() - d) { s = d - 1; } s += d; } if (s >= d) right = t; else left = t; } cout << right << endl; return 0; }