This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
int main()
{
cin.tie(0) -> sync_with_stdio(false);
ll n, m;
cin >> n >> m;
vector<ll> a(n), b(n);
for (auto &x : a)
cin >> x;
Loop (i,0,n) {
cin >> b[i];
a[i] = max(a[i], b[i]);
}
ll l = 0, r = 1e18;
while (l < r) {
ll target = (l+r+1)/2;
ll cnt = 0;
Loop (i,0,n) {
ll x = (target+a[i]-1)/a[i];
x = min(x, m);
if (x*a[i] < target)
x += (target - x*a[i] + b[i]-1)/b[i];
cnt += x;
}
if (cnt <= n*m)
l = target;
else
r = target-1;
}
cout << l << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |