Submission #585227

#TimeUsernameProblemLanguageResultExecution timeMemory
585227rgnerdplayerSelf Study (JOI22_ho_t2)C++17
0 / 100
304 ms8476 KiB
#include <bits/stdc++.h> using namespace std; using i64 = long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif auto solve = [&]() { int n, m; cin >> n >> m; vector<int> a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; a[i] = max(a[i], b[i]); } i64 lo = 0, hi = 1e18; while (lo < hi) { i64 md = lo + hi + 1 >> 1; i64 cnt = 0; for (int i = 0; i < n; i++) { if (md <= 1LL * m * a[i]) { cnt += (md + a[i] - 1) / a[i]; } else { cnt += m + (md - 1LL * a[i] * m + b[i] - 1) / b[i]; } } if (cnt <= 1LL * n * m) { lo = md; } else { hi = md - 1; } } cout << lo << '\n'; }; solve(); return 0; }

Compilation message (stderr)

Main.cpp: In lambda function:
Main.cpp:30:30: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   30 |             i64 md = lo + hi + 1 >> 1;
      |                      ~~~~~~~~^~~
#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...