#include <algorithm>
#include <iostream>
using namespace std;
const int N = 300000;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
int aa[N], bb[N];
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL);
int n, m; cin >> n >> m;
for (int i = 0; i < n; i++)
cin >> aa[i];
for (int i = 0; i < n; i++)
cin >> bb[i];
long long lower = 0, upper = INF;
while (upper - lower > 1) {
long long x = lower + upper >> 1;
long long d = 0;
for (int i = 0; i < n; i++) {
int a = aa[i], b = bb[i], c = max(a, b);
long long k = (x + c - 1) / c;
if (k <= m)
d += m - k;
else
d -= (x - (long long) c * m + b - 1) / b;
if (d < -INF)
break;
}
if (d >= 0)
lower = x;
else
upper = x;
}
cout << lower << '\n';
return 0;
}
| # | 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... |