Submission #536784

#TimeUsernameProblemLanguageResultExecution timeMemory
536784xp875Self Study (JOI22_ho_t2)C++17
10 / 100
84 ms5000 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]; if(m==1) { ll ans = (ll)1<<60; for(int i=0;i<n; i++) { ans = min(ans, max(a[i], b[i])); } cout << ans; return 0; } 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(a[i]>b[i]){ if(x > m*a[i]) ans += m + (x-a[i]*m+b[i]-1)/b[i]; else ans += (x+a[i]-1)/a[i]; } else ans += (x+b[i]-1)/b[i]; } if(ans <= n*m) lo = x; else hi = 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...