| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1358202 | nathako9n | Self Study (JOI22_ho_t2) | C++20 | 119 ms | 5128 KiB |
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=300005;
ll n,m,A[N+2],B[N+3];
ll ch(ll mid){
ll tot=0;
for(int i=1;i<=n;i++){
ll want=mid;
ll tclas=0,tself=0;
//cout<<i<<" "<<endl;
if(A[i]>B[i]){
tclas=want/A[i];
if(tclas*A[i]<want)++tclas;
tclas=min(tclas,m);
want-=tclas*A[i];
tot+=tclas;
}
if(want>0){
tself=want/B[i];
if(tself*B[i]<want)++tself;
tot+=tself;
}
//cout<<tclas<<" "<<tself<<endl<<endl;
}
return tot;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
// cout<<1;
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>A[i];
for(int i=1;i<=n;i++)cin>>B[i];
ll l=1,r=2e18,ans=-1;
while(l<=r){
ll mid=l+(r-l)/2;
if(ch(mid)<=n*m){
l=mid+1;
ans=mid;
}
else r=mid-1;
}
cout<<ans<<endl;
//cout<<ch(18);
cout<<endl;
return 0;
}
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
