Submission #936309

#TimeUsernameProblemLanguageResultExecution timeMemory
936309qwe1rt1yuiop1Self Study (JOI22_ho_t2)C++14
100 / 100
224 ms11348 KiB
#include <bits/stdc++.h> #define int long long using namespace std; void solve() { int n, m; cin >> n >> m; vector<int> a(n), b(n); for (int &i : a) cin >> i; for (int &i : b) cin >> i; int l = 0, r = 3e18; while (l + 1 < r) { int mid = (l + r) >> 1, lft = n * m; for (int i = 0; i < n && lft >= 0; ++i) if (a[i] <= b[i]) { int cnt = mid / b[i] + (mid % b[i] > 0); assert(cnt * b[i] >= mid && (cnt - 1) * b[i] < mid); lft -= cnt; } else { int cnt = mid / a[i] + (mid % a[i] > 0); cnt = min(cnt, m); lft -= cnt; if (lft < 0) break; if (cnt * a[i] < mid) { cnt = (mid - cnt * a[i]) / b[i] + ((mid - cnt * a[i]) % b[i] > 0); lft -= cnt; } } if (lft >= 0) l = mid; else r = mid; } cout << l << '\n'; } signed main() { ios::sync_with_stdio(0); cin.tie(0); 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...