#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m;
vector<ll> a, b;
bool F(ll x){
int r = 0;
for(int i = 0; i < n; i++){
if(x / a[i] >= m){
r += m - (x / a[i]) / m;
}
}
for(int i = 0; i < n; i++){
if(x / a[i] < m){
if(r >= m - x / a[i]){
r -= m - x / a[i];
}else{
return 0;
}
}
}
return 1;
}
int main(){
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];
for(int i = 0; i < n; i++) a[i] = max(a[i], b[i]);
ll lx = 0, rx = 1LL << 60;
while(rx - lx > 1){
ll mid = (rx + lx) / 2;
if(F(mid)) rx = mid;
else lx = mid;
}
cout << rx;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |