Submission #528776

#TimeUsernameProblemLanguageResultExecution timeMemory
528776FireGhost1301Self Study (JOI22_ho_t2)C++11
100 / 100
239 ms7212 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 3; int n, m, a[N], b[N]; bool check(long long d) { long long sum = 0; for (int i = 1; i <= n; ++i) { long long x = d; long long k = (x + a[i] - 1) / a[i]; k = min(k, (long long)m); x -= k * a[i]; sum += k; if (x > 0) sum += (x + b[i] - 1) / b[i]; if (sum > 1LL * n * m) return 0; } return 1; } void solve() { cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= n; ++i) cin >> b[i], a[i] = max(a[i], b[i]); long long l = 1, r = 1e18 + 7, ans = 0, mid; while (l <= r) { mid = (l + r) >> 1; if (check(mid)) ans = mid, l = mid + 1; else r = mid - 1; } cout << ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); 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...