Submission #786910

#TimeUsernameProblemLanguageResultExecution timeMemory
786910WLZSelf Study (JOI22_ho_t2)C++17
100 / 100
372 ms13840 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); 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]; for (int i = 0; i < n; i++) a[i] = max(a[i], b[i]); auto check = [&](__int128_t k) { vector<__int128_t> left(n, k); __int128_t weeks_left = (__int128_t) n * m; for (int i = 0; i < n; i++) { __int128_t div = min((__int128_t) m, (k + a[i] - 1) / a[i]); left[i] = max((__int128_t) 0, left[i] - a[i] * div); weeks_left -= div; } for (int i = 0; i < n; i++) weeks_left -= (left[i] + b[i] - 1) / b[i]; return weeks_left >= 0; }; __int128_t lo = 0, hi = (__int128_t) 2e18; while (lo < hi) { __int128_t mid = (lo + hi + 1) / 2; if (check(mid)) lo = mid; else hi = mid - 1; } cout << (long long) lo << '\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...