#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define ld long double
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n, m;cin>>n>>m;
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];
ll l(0), r = 2e18;
while(l<r){
ll mid = (l+r+1)/2;
//cout<<mid<<" "<<l<<" "<<r<<endl;
ll ext(0);
for(int i=0;i<n;i++){
ext += max((ll)(m - ceil((ld)mid/max(a[i], b[i]))), 0ll);
}
for(int i=0;i<n;i++){
if(m*max(a[i], b[i])>=mid)continue;
ll sm = ceil((ld)(mid - m*max(a[i], b[i]))/b[i]);
ext-=sm;
}
if(ext<-1)r=mid-1;
else l = mid;
}
cout<<l<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |