Submission #527826

#TimeUsernameProblemLanguageResultExecution timeMemory
527826JasiekstrzSelf Study (JOI22_ho_t2)C++17
100 / 100
245 ms7328 KiB
#include<bits/stdc++.h> #define fi first #define se second using namespace std; const int N=3e5; int a[N+10]; int b[N+10]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,m; cin>>n>>m; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++) cin>>b[i]; long long bg=1,en=1e18L+7; while(bg<en) { long long mid=(bg+en+1)/2; long long cnt=0; for(int i=1;i<=n;i++) { long long x=mid; if(a[i]>b[i]) { long long k=(x+a[i]-1)/a[i]; k=min(k,(long long)m); x-=k*a[i]; cnt+=k; } if(x>0) cnt+=(x+b[i]-1)/b[i]; if(cnt>(long long)n*m) break; } if(cnt<=(long long)n*m) bg=mid; else en=mid-1; } cout<<bg<<"\n"; return 0; }
#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...