#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
// freopen("a.in", "r", stdin);
cin.tie(0)->sync_with_stdio(0);
int 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];
for(int i = 0; i<n; ++i) a[i] = max(a[i], b[i]);
ll lo = 0, hi = 1e18;
while(lo<hi){
ll mid = lo+(hi-lo+1)/2;
ll cnt = 0;
for(int i = 0; i<n; ++i)
if(a[i]*m>=mid) cnt += m-(mid+a[i]-1)/a[i];
else cnt -= (mid-a[i]*m+b[i]-1)/b[i];
if(cnt>=0) lo = mid;
else hi = mid-1;
}
cout << lo << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
460 KB |
Output is correct |
11 |
Correct |
165 ms |
9548 KB |
Output is correct |
12 |
Correct |
169 ms |
9380 KB |
Output is correct |
13 |
Correct |
155 ms |
6596 KB |
Output is correct |
14 |
Incorrect |
305 ms |
8600 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
94 ms |
4780 KB |
Output is correct |
10 |
Correct |
57 ms |
2696 KB |
Output is correct |
11 |
Correct |
40 ms |
2140 KB |
Output is correct |
12 |
Correct |
33 ms |
1844 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
308 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
312 KB |
Output is correct |
18 |
Incorrect |
5 ms |
332 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
460 KB |
Output is correct |
11 |
Correct |
165 ms |
9548 KB |
Output is correct |
12 |
Correct |
169 ms |
9380 KB |
Output is correct |
13 |
Correct |
155 ms |
6596 KB |
Output is correct |
14 |
Incorrect |
305 ms |
8600 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
94 ms |
4780 KB |
Output is correct |
10 |
Correct |
57 ms |
2696 KB |
Output is correct |
11 |
Correct |
40 ms |
2140 KB |
Output is correct |
12 |
Correct |
33 ms |
1844 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
308 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
312 KB |
Output is correct |
18 |
Incorrect |
5 ms |
332 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
460 KB |
Output is correct |
11 |
Correct |
165 ms |
9548 KB |
Output is correct |
12 |
Correct |
169 ms |
9380 KB |
Output is correct |
13 |
Correct |
155 ms |
6596 KB |
Output is correct |
14 |
Incorrect |
305 ms |
8600 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |