Submission #1174820

#TimeUsernameProblemLanguageResultExecution timeMemory
1174820TsaganaSelf Study (JOI22_ho_t2)C++17
100 / 100
88 ms4936 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define int long long #define pq priority_queue #define eb emplace_back #define lb lower_bound #define ub upper_bound #define pb push_back #define pp pop_back #define F first #define S second using namespace std; int n, k; int a[300010]; int b[300010]; bool check(int m, int s = 0) { for (int i = 1; i <= n; i++) { if (a[i] * k >= m) s += (m + a[i] - 1) / a[i]; else s += k + (m - a[i] * k + b[i] - 1) / b[i]; if (s > n * k) return 0; } return 1; } int search(int l, int r) { while (l < r) { int m = (l + r + 1) / 2; if (check(m)) l = m; else r = m - 1; } return l; } void solve () { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; for (int i = 1; i <= n; i++) a[i] = max(a[i], b[i]); cout << search(0, 2e18) << '\n'; } signed main() {IOS solve(); return 0;}
#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...