Submission #1182853

#TimeUsernameProblemLanguageResultExecution timeMemory
1182853dima2101Self Study (JOI22_ho_t2)C++20
0 / 100
270 ms4936 KiB
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define int long long bool Check(std::vector<int>& a, std::vector<int>& b, int mid, int n, int m) { int cnt = 0; for (int i = 0; i < n; i++) { if (m * a[i] < mid) { // return false; assert(((mid - (m * a[i]) + b[i] - 1) / b[i]) >= 1); cnt -= ((mid - (m * a[i]) + b[i] - 1) / b[i]); // assert(cnt < 0); } else { int need = (mid + a[i] - 1) / a[i]; need = m - need; // assert(need >= 0); assert(need == 0); cnt += need; } } return (cnt >= 0); } int32_t main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n, m; std::cin >> n >> m; int min = 1e18; std::vector<int> a(n); std::vector<int> b(n); for (int i = 0; i < n; i++) std::cin >> a[i]; for (int i = 0; i < n; i++) std::cin >> b[i]; for (int i = 0; i < n; i++) { a[i] = std::max(a[i], b[i]); min = std::min(min, a[i]); } // std::cout << Check(a, b, 18, n, m) << std::endl; // return 0; int l = 0, r = (int)1e18 + 1; while (l + 1 < r) { int mid = (l + r) / 2; if (Check(a, b, mid, n, m)) { l = mid; } else { r = mid; } } std::cout << l; }
#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...