Submission #889827

#TimeUsernameProblemLanguageResultExecution timeMemory
889827arbuzickSelf Study (JOI22_ho_t2)C++17
100 / 100
203 ms8540 KiB
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; vector<int> a(n), b(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } for (int i = 0; i < n; ++i) { cin >> b[i]; } long long l = 0, r = 1000000000 * 1LL * 1000000000 + 7; while (l < r - 1) { long long md = (l + r) / 2; long long free = 0; for (int i = 0; i < n; ++i) { if (a[i] <= b[i]) { free += m; free -= (md - 1) / b[i] + 1; } else if (a[i] * 1LL * m >= md) { long long vl = (md - 1) / a[i] + 1; free += m - vl; } else { free -= (md - a[i] * 1LL * m - 1) / b[i] + 1; } if (free < -n * 1LL * m) { break; } } if (free >= 0) { l = md; } else { r = md; } } cout << l << '\n'; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); } 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...