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>
#define ll long long
using namespace std;
ll ori[2][3000010]={};
const ll maxn=1e18+100;
int main(){
ll n,w;
cin>>n>>w;
for(int i=0;i<n;i++){
cin>>ori[0][i];
}
for(int i=0;i<n;i++){
cin>>ori[1][i];
}
ll l=1,r=maxn;
while(l!=r){
ll m=(l+r+1)/2,c=0;
for(int i=0;i<n;i++){
c+=w;
if(ori[0][i]>ori[1][i]){
if(ori[0][i]*w>=m){
c-=((m-1)/ori[0][i])+1;
}else{
c-=w;
c-=((m-ori[0][i]*w-1)/ori[1][i])+1;
}
}else{
c-=((m-1)/ori[1][i])+1;
}
}
if(c>=0){
l=m;
}else{
r=m-1;
}
}
cout<<l<<'\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... |