Submission #528771

#TimeUsernameProblemLanguageResultExecution timeMemory
528771FireGhost1301Self Study (JOI22_ho_t2)C++11
0 / 100
301 ms7108 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) { if (1LL * a[i] * m >= d) sum += (d + a[i] - 1) / a[i]; else sum += m + (d - 1LL * a[i] * m + b[i] - 1) / b[i]; } return sum <= 1LL * n * m; } 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, ans, 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...