# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
684780 | US3RN4M3 | Self Study (JOI22_ho_t2) | C++17 | 198 ms | 2644 KiB |
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;
using ll = long long;
ll n, m;
vector<ll> A;
vector<ll> B;
bool test(ll goal) {
ll avail = 0;
for(ll i = 0; i < n; i++) {
ll used = (goal - 1)/A[i] + 1;
if(used <= m) {
avail += m - used;
if(m == 1) assert(used == 1);
continue;
}
if(m == 1) continue;
ll left = goal - A[i]*m;
ll req = (left - 1)/B[i] + 1;
avail -= req;
}
if(m == 1) return true;
return (avail >= 0);
}
main() {
cin >> n >> m;
A.resize(n);
B.resize(n);
for(ll & i : A) cin >> i;
for(ll & i : B) cin >> i;
for(int i = 0; i < n; i++) A[i] = max(A[i], B[i]);
ll ans = 0;
for(ll delta = (1ll<<60); delta >= 1; delta >>= 1) {
if(test(ans + delta)) ans += delta;
}
//ll ans2 = 1e18;
//for(ll i = 0; i < n; i++) ans2 = min(ans2, max(A[i], B[i]));
//if(m == 1 && ans2 != ans) assert(ans2 > ans);
cout << ans << endl;
}
Compilation message (stderr)
# | 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... |