#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, m;
cin >> n >> m;
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];
ll lo = 0, hi = (ll)1<<60;
while(hi-lo>1) {
ll x = (lo+hi)/2;
ll ans = 0;
for(int i=0; i<n; i++) {
ll a1 = (x+b[i]-1)/b[i];
ll a2 = (x+a[i]-1)/a[i];
if(a2 > m) a2 = m + (x-a[i]*m+b[i]-1)/b[i];
ans += min(a1, a2);
}
if(ans <= n*m) lo = x;
else hi = x;
}
cout << lo;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
9 ms |
284 KB |
Output is correct |
11 |
Correct |
528 ms |
5068 KB |
Output is correct |
12 |
Correct |
528 ms |
4972 KB |
Output is correct |
13 |
Correct |
596 ms |
5068 KB |
Output is correct |
14 |
Incorrect |
896 ms |
4968 KB |
Output isn't correct |
15 |
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 |
1 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 |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
263 ms |
2624 KB |
Output is correct |
10 |
Correct |
181 ms |
1836 KB |
Output is correct |
11 |
Correct |
139 ms |
1440 KB |
Output is correct |
12 |
Correct |
108 ms |
1212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Incorrect |
15 ms |
364 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
9 ms |
284 KB |
Output is correct |
11 |
Correct |
528 ms |
5068 KB |
Output is correct |
12 |
Correct |
528 ms |
4972 KB |
Output is correct |
13 |
Correct |
596 ms |
5068 KB |
Output is correct |
14 |
Incorrect |
896 ms |
4968 KB |
Output isn't correct |
15 |
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 |
1 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 |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
263 ms |
2624 KB |
Output is correct |
10 |
Correct |
181 ms |
1836 KB |
Output is correct |
11 |
Correct |
139 ms |
1440 KB |
Output is correct |
12 |
Correct |
108 ms |
1212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Incorrect |
15 ms |
364 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
9 ms |
284 KB |
Output is correct |
11 |
Correct |
528 ms |
5068 KB |
Output is correct |
12 |
Correct |
528 ms |
4972 KB |
Output is correct |
13 |
Correct |
596 ms |
5068 KB |
Output is correct |
14 |
Incorrect |
896 ms |
4968 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |