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>
typedef long long ll;
#define fastio cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
using namespace std;
inline ll divide(ll a, ll d){
return (a-1)/d+1;
}
int main(){
fastio
int n;
ll m, l = 1, r = 1e18;
cin >> n >> m;
ll lesson = m*n;
vector<ll> a(n), b(n);
for(int i=0; i<n; i++) cin >> a[i];
for(int i=0; i<n; i++){
cin >> b[i];
a[i] = max(a[i], b[i]);
}
while(l!=r){
ll g = (l+r+1)>>1, cnt = 0;
for(int i=0; i<n; i++){
ll tmp = divide(g, a[i]);
if(tmp>m) cnt += m+divide(g-a[i]*m, b[i]);
else cnt += tmp;
if(cnt>lesson) break;
}
if(cnt>lesson) r = g-1;
else l = g;
}
cout << r << '\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... |