Submission #704100

#TimeUsernameProblemLanguageResultExecution timeMemory
704100ld_minh4354Self Study (JOI22_ho_t2)C++17
100 / 100
250 ms11440 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pb push_back #define debug(x) cout<<#x<<": "<<x<<"\n" signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // freopen("input.000","r",stdin); // freopen("output.000","w",stdout); // srand((unsigned)time(NULL)); // rand() int n,a[300005],b[300005],i,ans,l,r,w,m,sum; cin>>n>>m; for (i=1;i<n+1;i++) cin>>a[i]; for (i=1;i<n+1;i++) cin>>b[i]; ans=0;l=0;r=1e18; while (l<=r) { w=(l+r)/2; bool tr=true; sum=0; for (i=1;i<n+1;i++) { if (a[i]>b[i]) { if (a[i]*m>=w) sum += w/a[i] + (w%a[i]!=0); else sum += m + (w-a[i]*m)/b[i] + ((w-a[i]*m)%b[i]!=0); } else sum += w/b[i] + (w%b[i]!=0); if (sum>n*m) tr=false; } if (tr) { ans=w;l=w+1; } else r=w-1; } cout<<ans; }
#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...