#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m;
vector<int> a,b;
int dv(int x,int y){
if(y*(x/y)==x) return x/y;
else return x/y+1;
}
bool check(int x){
int emp=0,ext=0;
for(int i=0;i<n;i++){
emp+=max(m-dv(x,a[i]),0LL);
ext+=max(dv(x-m*a[i],b[i]),0LL);
}
return emp>=ext;
}
signed main(){
cin>>n>>m;
a.resize(n);
b.resize(n);
for(int &i:a) cin>>i;
for(int i=0;i<n;i++){
cin>>b[i];
a[i]=max(a[i],b[i]);
}
int l=0,r=1e18,mid;
while(r-l>1){
mid=(l+r)/2;
if(check(mid)) l=mid;
else r=mid;
}
cout<<l<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 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 |
0 ms |
344 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 |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |