#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define fs first
#define sc second
const ll mxn = 3e5+10;
ll N,M;
ll arr[mxn],brr[mxn];
ll f(ll tar){
ll re = 0;
for(int i = 1;i<=N;i++){
if(arr[i]*M>=tar){
re += M-(tar+arr[i]-1)/arr[i];
}
else{
ll tmp = tar-arr[i]*M;
re -= (tmp+brr[i]-1)/brr[i];
}
}
return re>=0;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>M;
for(int i = 1;i<=N;i++)cin>>arr[i];
for(int i = 1;i<=N;i++)cin>>brr[i],arr[i] = max(arr[i],brr[i]);
ll l = 0,r = 2e18;
while(l != r){
ll mid = (l+r+1)>>1;
if(f(mid))l = mid;
else r = mid-1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |