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;
#define int long long
void solve(){
int n,m;cin >> n >> m;
int 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]);
}
int l = 0 , r = 1ll << 60;
while(l < r){
int mid = (l+r)/2;
int day = 0 , fail = 0;
for(int i = 0;i<n;i++){
if(mid <= a[i] * m){
day += (mid + a[i] - 1) / a[i];
}
else {
day += m + (mid - a[i] * m + b[i] - 1) / b[i];
}
if(day > n * m){fail = 1;}
}
if(fail)r = mid;
else l = mid+1;
}
cout << l-1 << endl;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase = 1;//cin >> testcase;
while(testcase--)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... |