Submission #1018789

#TimeUsernameProblemLanguageResultExecution timeMemory
1018789Bilal_CoderSelf Study (JOI22_ho_t2)C++17
0 / 100
228 ms5124 KiB
#include "bits/stdc++.h" using namespace std; #define int long long /* ▀█████████▄ ▄█ ▄█ ▄████████ ▄█ ▄████████ ▄██████▄ ████████▄ ▄████████ ▄████████ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ▀███ ███ ███ ███ ███ ███ ███ ███▌ ███ ███ ███ ███ ███ █▀ ███ ███ ███ ███ ███ █▀ ███ ███ ▄███▄▄▄██▀ ███▌ ███ ███ ███ ███ ███ ███ ███ ███ ███ ▄███▄▄▄ ▄███▄▄▄▄██▀ ▀▀███▀▀▀██▄ ███▌ ███ ▀███████████ ███ ███ ███ ███ ███ ███ ▀▀███▀▀▀ ▀▀███▀▀▀▀▀ ███ ██▄ ███ ███ ███ ███ ███ ███ █▄ ███ ███ ███ ███ ███ █▄ ▀███████████ ███ ███ ███ ███▌ ▄ ███ ███ ███▌ ▄ ███ ███ ███ ███ ███ ▄███ ███ ███ ███ ███ ▄█████████▀ █▀ █████▄▄██ ███ █▀ █████▄▄██ ████████▀ ▀██████▀ ████████▀ ██████████ ███ ███ ▀ ▀ ███ ███ */ template<class T> bool setmax(T& a, const T& b){ return b < a ? a = b, 1 : 0; } template<class T> bool setmin(T& a, const T& b){ return a < b ? a = b, 1 : 0; } signed main() { int n , m; cin >> n >> m; vector<int> a(n) , b(n); for (auto & x : a) cin >> x; for (auto & x : b) cin >> x; auto check = [&](int p){ int t = 0; for (int i = 0; i < n; i++){ if (b[i] > a[i]) t += (p + b[i] - 1) / b[i]; else { if (a[i] * 1ll * m >= p) t += (p + a[i] - 1) / a[i]; else t += m + (p - a[i] * 1ll * m + b[i] - 1) / b[i]; } } if (t <= n * 1ll * m) return true; return false; }; int l = 0 , r = 1e18; while(l < r){ int m = (l + r + 1) >> 1; if (check(m)) l = m; else r = m - 1; } cout << l << "\n"; 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...