Submission #800276

#TimeUsernameProblemLanguageResultExecution timeMemory
800276caganyanmazSelf Study (JOI22_ho_t2)C++17
100 / 100
366 ms13792 KiB
#include <bits/stdc++.h> #define int int64_t using namespace std; constexpr static int MXSIZE = 3e5; int n, m, a[MXSIZE], b[MXSIZE], v[MXSIZE]; int ceil(int aa, int bb) { return (aa + bb-1) / bb; } int possible(int k) { for (int i = 0; i < n; i++) v[i] = 0; int r = n*m; for (int i = 0; i < n; i++) { if (a[i] < b[i]) continue; int s = min(ceil(k, a[i]), m); v[i] = s * a[i]; r -= s; } for (int i = 0; i < n; i++) { if (k > v[i]) r -= ceil(k - v[i], b[i]); if (r < 0) return false; } return true; } int32_t main() { cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; int l = -1, r = 2e18; while (r - l > 1) { int m = l+r>>1; if (possible(m)) l = m; else r = m; } cout << l << "\n"; }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:46:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |                 int m = l+r>>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...