#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug if(0)
const ll inf = 1e18+4;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, m; cin>>n>>m;
vector<ll> a(n), b(n);
for(int i=0; i<n; i++) cin>>a[i];
for(int i=0; i<n; i++) cin>>b[i];
// A = B subtask
auto check = [&](ll x) {
// if can be done with minimum >= x
ll res = 0;
for(int i=0; i<n; i++) {
ll y = (x+(b[i]-1))/b[i];
//debug cerr<<"x: "<<x<<", b[i] = "<<b[i]<<" ; y = "<<y<<"\n";
res += y;
}
//debug cerr<<"x: "<<x<<", res = "<<res<<" ; n*m = "<<n*m<<"\n";
return res <= (n*m);
};
ll lo = 0, hi = inf;
while(lo < hi) {
ll m = (lo+hi+1)/2LL;
if(check(m)) lo = m;
else hi = m-1;
}
cout<<lo<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
324 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
320 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
81 ms |
5480 KB |
Output is correct |
10 |
Correct |
54 ms |
3804 KB |
Output is correct |
11 |
Correct |
42 ms |
2892 KB |
Output is correct |
12 |
Correct |
34 ms |
2500 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Incorrect |
5 ms |
340 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
324 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
320 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
81 ms |
5480 KB |
Output is correct |
10 |
Correct |
54 ms |
3804 KB |
Output is correct |
11 |
Correct |
42 ms |
2892 KB |
Output is correct |
12 |
Correct |
34 ms |
2500 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Incorrect |
5 ms |
340 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
324 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |