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;
int n, m;
vector<ll> a, b;
bool F(ll x){
int r = 0;
for(int i = 0; i < n; i++){
if(x / a[i] >= m){
r += m - (x / a[i]) / m;
}
}
for(int i = 0; i < n; i++){
if(x / a[i] < m){
if(r >= m - x / a[i]){
r -= m - x / a[i];
}else{
return 0;
}
}
}
return 1;
}
int main(){
cin >> n >> m;
a.resize(n);
b.resize(n);
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n; i++) cin >> b[i];
for(int i = 0; i < n; i++) a[i] = max(a[i], b[i]);
ll lx = 0, rx = 1LL << 60;
while(rx - lx > 1){
ll mid = (rx + lx) / 2;
if(F(mid)) rx = mid;
else lx = mid;
}
cout << rx;
}
# | 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... |