Submission #536801

#TimeUsernameProblemLanguageResultExecution timeMemory
536801xp875Self Study (JOI22_ho_t2)C++17
100 / 100
244 ms5068 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n, m; cin >> n >> m; ll a[n], b[n]; for(int i=0; i<n; i++) cin >> a[i]; for(int i=0; i<n; i++) cin >> b[i]; ll lo = 0, hi = (ll)1<<60; while(hi-lo>1) { ll x = (lo+hi)/2; ll ans = 0; for(int i=0; i<n; i++) { if(b[i]>=a[i]) { ans += (x+b[i]-1)/b[i]; } else { if(x>m*a[i]) ans += m + (x-a[i]*m+b[i]-1)/b[i]; else ans += (x+a[i]-1)/a[i]; } if(ans > n*m) { hi = x; break; } } if(ans<=n*m) lo = x; } cout << lo; }
#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...