제출 #593562

#제출 시각아이디문제언어결과실행 시간메모리
593562piOOESelf Study (JOI22_ho_t2)C++17
100 / 100
236 ms5708 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; const ll inf = 3e18; vector<ll> a(n), b(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } for (int i = 0; i < n; ++i) { cin >> b[i]; } ll L = 0, R = inf; while (L + 1 < R) { ll mid = (L + R) >> 1; auto check = [&]() -> bool { ll cnt = n * (ll)m; for (int i = 0; i < n; ++i) { if (b[i] >= a[i]) { ll now = (mid + b[i] - 1) / b[i]; cnt -= now; } else { ll now = (mid + a[i] - 1) / a[i]; if (now <= m) { cnt -= now; } else { ll whole = m + (mid - a[i] * m + b[i] - 1) / b[i]; cnt -= whole; } } if (cnt < 0) { return false; } } return true; }; if (check()) { L = mid; } else { R = mid; } } cout << L; 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...