This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define fi first
#define se second
int n,k;
int A[300005], B[300005], P[200005];
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], A[i] = max(A[i], B[i]);
int s = 0, e = 5e18, ans = s;
while(s <= e){
int m = s + (e-s)/2;
int cnt = 0;
for(int i=1;i<=n;i++){
if(A[i]*k < m)cnt -= ((m - A[i] * k + B[i] - 1)/ B[i]);
else {
int x = (m + A[i] - 1) / A[i];
cnt += k - x;
}
}
if(cnt >= 0)ans = m, s = m + 1;
else e = m - 1;
}
cout << ans;
}
main(){
ios::sync_with_stdio(0);cin.tie(0);
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
Compilation message (stderr)
Main.cpp:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
32 | main(){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |