Submission #879935

#TimeUsernameProblemLanguageResultExecution timeMemory
879935frostray8653Self Study (JOI22_ho_t2)C++17
100 / 100
381 ms5200 KiB
#include <bits/stdc++.h> #define int long long #define IO ios::sync_with_stdio(0), cin.tie(0) #define FOR(i, a, b) for (int i = a; i <= b; i++) using namespace std; using pii = pair<int, int>; const int N = 300005; const int INF = 2e18; int n, m; int a[N], b[N]; bool check(int k) { __int128_t cst_day = 0; for (int i = 1; i <= n; i++) { if (a[i] >= b[i]) { __int128_t need = (k + a[i] - 1) / a[i]; if (need > m) { __int128_t less = k - m * a[i]; cst_day += (less + b[i] - 1) / b[i]; } else { cst_day -= m - need; } } else { __int128_t need = (k + b[i] - 1) / b[i]; if (need > m) cst_day += need - m; else cst_day -= m - need; } } return (cst_day <= 0); } signed main() { IO; cin >> n >> m; FOR(i, 1, n) cin >> a[i]; FOR(i, 1, n) cin >> b[i]; __int128_t l = 0, r = 10000; while (check(r)) r *= 2; while (l + 1 < r) { __int128_t mid = (l + r) >> 1; if (check(mid)) l = mid; else r = mid; } int ans = l; cout << ans << "\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...