Submission #939659

#TimeUsernameProblemLanguageResultExecution timeMemory
939659TAhmed33Self Study (JOI22_ho_t2)C++98
0 / 100
429 ms11088 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 3e5 + 25; ll n, m; pair <ll, ll> a[MAXN]; void solve () { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i].first; for (int i = 1; i <= n; i++) cin >> a[i].second; for (int i = 1; i <= n; i++) a[i].first = max(a[i].first, a[i].second); ll l = 0, r = 1e18, ans = 0; while (l <= r) { ll mid = (l + r) / 2; ll sum = 0; for (int i = 1; i <= n; i++) { ll x = (mid + a[i].first - 1) / a[i].first; if (x <= m) { sum += x; } else { sum += (mid - a[i].first * m + a[i].second - 1) / a[i].second + m; } } if (sum <= n * m) { l = mid + 1; ans = mid; } else { r = mid - 1; } } cout << ans << '\n'; } int main () { ios::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; while (t--) solve(); }
#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...