Submission #538668

#TimeUsernameProblemLanguageResultExecution timeMemory
538668farukSelf Study (JOI22_ho_t2)C++17
100 / 100
292 ms5068 KiB
#include <bits/stdc++.h> #define pii pair<int, int> #define ll long long #define ld long double using namespace std; vector<ll> a; vector<ll> b; int n; ll m; bool binary(ll x) { ll possible = 0; for (int i = 0; i < n ; i++) { ll val = a[i] * m; if (val < x) continue; ll diff = val - x; possible += diff / a[i]; } for (int i = 0; i < n; i++) { ll val = a[i] * m; if (val >= x) continue; ll dif = x - val; possible -= ceil((ld)dif / (ld)b[i]); } return possible < 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; a.resize(n); b.resize(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]); } ll l = 0, r = 6e18; while (l < r) { ll mid = (l + r) / 2; if (binary(mid)) r = mid; else l = mid + 1; } cout << l - 1<< "\n"; }
#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...