Submission #727388

#TimeUsernameProblemLanguageResultExecution timeMemory
727388khanhdz06Self Study (JOI22_ho_t2)C++17
0 / 100
1 ms212 KiB
#include<iostream> #include<vector> #include<algorithm> using namespace std; typedef long long ll; typedef pair<ll,ll> pl; const ll maxn=300010; ll n,m; ll a[maxn],b[maxn]; bool chk(ll x) { ll ret=0; for(ll i=1;i<=n;i++) { if(a[i]<=b[i]) ret+=(x+b[i]-1)/b[i]; else { ll kappa=(x+a[i]-1)/a[i]; kappa=min(kappa,m); ret+=kappa; ll h=kappa*a[i]; if(x>h) ret+=((x-h)+b[i]-1)/b[i]; if(ret>n*m) return 0; } } return 1; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin>>n>>m; for(ll i=1;i<=n;i++) cin>>a[i]; for(ll i=1;i<=n;i++) cin>>b[i]; ll lo=0,hi=1e18; while(lo<hi) { ll m=(lo+hi)/2; if(chk(m)) lo=m+1; else hi=m-1; } cout<<lo; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...