Submission #991162

#TimeUsernameProblemLanguageResultExecution timeMemory
991162OtalpSelf Study (JOI22_ho_t2)C++14
0 / 100
248 ms5044 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define int ll ll a[300100]; ll b[300100]; ll n, m; bool check(ll x){ ll h = 0; //cout<<x<<' '; for(int i=1; i<=n; i++){ if(a[i] > b[i]){ if(m * a[i] < x){ h += m; h += (x - m * a[i] - 1) / b[i] + 1; } else{ h += (x - 1) / a[i] + 1; } } else{ h += (x - 1) / b[i] + 1; } } //cout<<h<<'\n'; return h <= m*n; } void solve(){ 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=0, r=2e18; while(l < r){ ll mid=(l+r)/2; if(check(mid)) l = mid + 1; else r = mid; } cout<<r - 1; } signed main(){ solve(); }
#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...