Submission #906475

#TimeUsernameProblemLanguageResultExecution timeMemory
906475OAleksaSelf Study (JOI22_ho_t2)C++14
100 / 100
224 ms11604 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define f first #define s second signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt = 1; //cin >> tt; while (tt--) { int n, m; cin >> n >> m; vector<int> a(n); for (int i = 0;i < n;i++) cin >> a[i]; vector<int> b(n); for (int i = 0;i < n;i++) cin >> b[i]; int l = 0, r = 1e18, ans = 0; auto check = [&](int mid) { int uk = n * m; for (int i = 0;i < n;i++) { int d = 0, t = mid; if (a[i] > b[i]) { int x = min(m, (t + a[i] - 1) / a[i]); t -= x * a[i]; d += x; } if (t > 0) d += (t + b[i] - 1) / b[i]; if (d > uk) return false; uk -= d; } return true; }; while (l <= r) { int mid = l + (r - l) / 2; if (check(mid)) { ans = mid; l = mid + 1; } else r = mid - 1; } cout << ans << '\n'; } return 0; }
#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...