Submission #1000799

#TimeUsernameProblemLanguageResultExecution timeMemory
1000799HanksburgerSelf Study (JOI22_ho_t2)C++17
100 / 100
146 ms11532 KiB
#include <bits/stdc++.h> using namespace std; long long a[300005], b[300005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m, l=0, r=2e18; cin >> n >> m; for (long long i=1; i<=n; i++) cin >> a[i]; for (long long i=1; i<=n; i++) cin >> b[i]; while (l<r) { long long mid=(l+r+1)/2, cnt=0; for (long long i=1; i<=n; i++) { if (a[i]<b[i]) cnt+=(mid-1)/b[i]+1; else if (mid<=a[i]*m) cnt+=(mid-1)/a[i]+1; else cnt+=m+(mid-a[i]*m-1)/b[i]+1; if (cnt>2e18) break; } if (cnt<=n*m) l=mid; else r=mid-1; } cout << l; }
#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...