Submission #538667

#TimeUsernameProblemLanguageResultExecution timeMemory
538667Harry464Self Study (JOI22_ho_t2)C++14
100 / 100
439 ms7452 KiB
#include <cmath> #include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; int main(){ ll n, m; cin >> n >> m; vector <ll> a(n); vector <ll> b(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; for (int i = 0; i < n; i++) a[i] = max(a[i], b[i]); ll l = 1, r = 1000000000000000001; ll granica = n*m; while (l < r){ ll mid = (l+r)/2; ll potrebno = (ll) 0; for (int i = 0; i < n; i++){ if (potrebno > granica) break; ll maksa = mid/a[i]; if (mid%a[i] != 0) maksa++; potrebno += min(maksa, m); ll iskor = min(maksa, m); ll maksb = (mid- iskor*a[i])/b[i]; if(mid-iskor*a[i] < 0) continue; if((mid - iskor*a[i])%b[i] != 0) maksb++; potrebno += maksb; } if (potrebno <= granica) l = mid + 1; else r = mid; } cout << l - 1; }
#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...