Submission #703252

#TimeUsernameProblemLanguageResultExecution timeMemory
703252MilosMilutinovicSelf Study (JOI22_ho_t2)C++14
100 / 100
252 ms9104 KiB
/** * author: wxhtzdy * created: 26.02.2023 19:18:55 **/ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> b(n); for (int i = 0; i < n; i++) { cin >> b[i]; if (a[i] < b[i]) { a[i] = b[i]; } } auto Solve = [&](long long x) { long long f = 0; for (int i = 0; i < n; i++) { if (m * 1LL * a[i] >= x) { long long take = (x + a[i] - 1) / a[i]; f += m - take; } } for (int i = 0; i < n; i++) { if (m * 1LL * a[i] < x) { long long need = (x - m * 1LL * a[i] + b[i] - 1) / b[i]; f -= need; if (f < 0) { return false; } } } return f >= 0; }; long long low = 0, high = 1e18, ans = 0; while (low <= high) { long long mid = low + high >> 1; if (Solve(mid)) { ans = mid; low = mid + 1; } else { high = mid - 1; } } cout << ans << '\n'; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:46:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |     long long mid = low + high >> 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...