Submission #868931

#TimeUsernameProblemLanguageResultExecution timeMemory
868931rockstarSelf Study (JOI22_ho_t2)C++17
100 / 100
207 ms11592 KiB
//#pragma GCC optimize("O3,unroll-loops,inline,fast-math") #include <bits/stdc++.h> using namespace std; using ll = long long; using lint = __int128_t; #define all(a) (a).begin(), (a).end() #define int ll void solve() { int n, m; cin >> n >> m; vector<int> a(n), b(n); for (int& i : a) cin >> i; for (int& i : b) cin >> i; for (int i = 0; i < n; ++i) a[i] = max(a[i], b[i]); lint l = 0, r = 1e18 + 228; while (r - l > 1) { lint mid = (l + r) / 2; lint free = 0, need = 0; for (int i = 0; i < n; ++i) { if ((lint)m * a[i] < mid) { lint x = mid - (lint)m * a[i]; need += x / b[i] + bool(x % b[i]); } else { free += m - (mid / a[i] + bool(mid % a[i])); } } if (free >= need) l = mid; else r = mid; } cout << (int)l; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); 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...