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>
using namespace std;
#ifdef MIKU
const string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define int long long
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;
const int MXN = 300005, INF = 3.9e18;
int n, m, a[MXN], b[MXN];
int DC(int a, int b) {
return (a - 1) / b + 1;
}
bool check(int x) {
// int now = 0;
// FOR(i, 0, n) {
// if (a[i] > b[i]) {
// if (a[i] * m >= x) now += m - DC(x, a[i]);
// else now -= DC(x - a[i] * m, b[i]);
// } else {
// now += m - DC(x, b[i]);
// }
// }
int now = n * m;
FOR(i, 0, n) {
now -= DC(x, b[i]);
}
return (now >= 0);
}
int miku() {
cin >> n >> m;
FOR(i, 0, n) cin >> a[i];
FOR(i, 0, n) cin >> b[i];
int l = 0, r = INF;
while (l + 1 < r) {
int mid = (l + r) >> 1;
(check(mid) ? l : r) = mid;
}
return l;
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cin.exceptions(cin.failbit);
cout << miku() << '\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... |