Submission #824341

#TimeUsernameProblemLanguageResultExecution timeMemory
824341petezaSelf Study (JOI22_ho_t2)C++14
100 / 100
342 ms5024 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll n, m; ll l=0, r=1e18, mid; ll a[300005], b[300005]; int main() { cin.tie(0) -> sync_with_stdio(0); cin >> n >> m; for(int i=0;i<n;i++) cin >> a[i]; for(int i=0;i<n;i++) { cin >> b[i]; a[i] = max(a[i], b[i]); } while(l <= r) { mid = (l+r) >> 1; double treq=0, tfree=0; for(int i=0;i<n;i++) { ll times = (mid+a[i]-1)/a[i]; if(times > m) treq += (mid-m*a[i]+b[i]-1)/b[i]; else tfree += (m-times); } if(tfree >= treq) l = mid + 1; else r = mid - 1; } cout << r; }
#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...