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;
typedef long long ll;
const int MAXN = 3e5 + 25;
ll n, m;
pair <ll, ll> a[MAXN];
void solve () {
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i].first;
for (int i = 1; i <= n; i++) cin >> a[i].second;
for (int i = 1; i <= n; i++) a[i].first = max(a[i].first, a[i].second);
ll l = 0, r = 1e18, ans = 0;
while (l <= r) {
ll mid = (l + r) / 2;
ll sum = 0;
for (int i = 1; i <= n; i++) {
ll x = (mid + a[i].first - 1) / a[i].first;
if (x <= m) {
sum += x;
} else {
sum += (mid - a[i].first * m + a[i].second - 1) / a[i].second + m;
}
}
if (sum <= n * m) {
l = mid + 1; ans = mid;
} else {
r = mid - 1;
}
}
cout << ans << '\n';
}
int main () {
ios::sync_with_stdio(0); cin.tie(0);
int t = 1; //cin >> t;
while (t--) solve();
}
# | 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... |