Submission #921489

#TimeUsernameProblemLanguageResultExecution timeMemory
921489cthbstSelf Study (JOI22_ho_t2)C++14
62 / 100
326 ms11052 KiB
#include <algorithm> #include <cmath> #include <iostream> #define int long long using namespace std; const int MAXN = 300005; int n, m; int a[MAXN]; int b[MAXN]; void init() { cin >> n >> m; 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]); } bool check(int D) { __int128 extra = 0; // cout << "D = " << D << '\n'; for (int i = 0; i < n; i++) { if (a[i] * m >= D) { extra += m - ceil(1.0 * D / a[i]); } else { // a[i] * m < D extra -= ceil(1.0 * (D - a[i] * m) / b[i]); } } return extra >= 0; } void solve() { int l = 1; int r = 1 + (int)1e18; // check(D) : D 愈小愈容易 while (l != r) { int mid = (l + r) / 2; if (check(mid) == false) { r = mid; } else { l = mid + 1; } } int ans = r - 1; cout << ans << '\n'; } signed main() { cin.tie(0); cin.sync_with_stdio(0); init(); 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...