Submission #923429

#TimeUsernameProblemLanguageResultExecution timeMemory
923429dreamoonSelf Study (JOI22_ho_t2)C++14
0 / 100
270 ms5204 KiB
#include<bits/stdc++.h> #define int long long #define pii pair<int, int> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<int>a(n), b(n); for (auto &i : a) cin >> i; for (auto &i : b) cin >> i; int l = -1, r = (long long)(1e18) + 5, mid; while (l + 1 < r) { mid = (l + r) / 2; int need = 0; for (int i = 0 ; i < n ; i++) { if (a[i] > b[i]) { if (mid > a[i] * m) need += m + (mid - a[i] * m) / b[i] + ((mid - a[i] * m) % b[i] != 0ll ? 1ll : 0ll); else need += (mid / a[i]) + (mid % a[i] != 0ll ? 1ll : 0ll); } else { need += (mid / b[i]) + (mid % b[i] != 0ll ? 1ll : 0ll); } } if (need <= n * m) { l = mid; //cout << l << " " << need << "\n"; } else { r = mid; } } cout << l << "\n"; }
#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...