#include <bits/stdc++.h>
using namespace std;
long long N, M;
long long A[300001], B[300001];
bool check(long long X) {
long long day = 0;
for (int i = 1; i <= N; i++) {
if (X <= A[i]*M) {
day += (X+A[i]-1)/A[i];
}
else {
day += M+(X-A[i]*M+B[i]-1)/B[i];
}
if (day > N*M) return false;
}
return true;
}
int main() {
cin >> N >> M;
for (int i = 1; i <= N; i++) {
cin >> A[i];
}
for (int i = 1; i <= N; i++) {
cin >> B[i];
A[i] = max(A[i], B[i]);
}
long long high = 1LL << 60;
long long low = 0;
while (high-low > 1) {
long long mid = (low+high)/2;
if (check(mid)) {
low = mid;
}
else {
high = mid;
}
}
cout << low << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
316 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
5 ms |
468 KB |
Output is correct |
11 |
Correct |
258 ms |
10736 KB |
Output is correct |
12 |
Correct |
271 ms |
10740 KB |
Output is correct |
13 |
Correct |
189 ms |
8800 KB |
Output is correct |
14 |
Correct |
179 ms |
8792 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
81 ms |
6084 KB |
Output is correct |
17 |
Correct |
275 ms |
11408 KB |
Output is correct |
18 |
Correct |
257 ms |
10712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
81 ms |
6084 KB |
Output is correct |
3 |
Correct |
275 ms |
11408 KB |
Output is correct |
4 |
Correct |
257 ms |
10712 KB |
Output is correct |
5 |
Correct |
1 ms |
268 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
128 ms |
5544 KB |
Output is correct |
14 |
Correct |
89 ms |
3708 KB |
Output is correct |
15 |
Correct |
71 ms |
2948 KB |
Output is correct |
16 |
Correct |
54 ms |
2296 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
316 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
6 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
316 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
5 ms |
468 KB |
Output is correct |
11 |
Correct |
258 ms |
10736 KB |
Output is correct |
12 |
Correct |
271 ms |
10740 KB |
Output is correct |
13 |
Correct |
189 ms |
8800 KB |
Output is correct |
14 |
Correct |
179 ms |
8792 KB |
Output is correct |
15 |
Correct |
1 ms |
268 KB |
Output is correct |
16 |
Correct |
1 ms |
316 KB |
Output is correct |
17 |
Correct |
1 ms |
312 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
128 ms |
5544 KB |
Output is correct |
24 |
Correct |
89 ms |
3708 KB |
Output is correct |
25 |
Correct |
71 ms |
2948 KB |
Output is correct |
26 |
Correct |
54 ms |
2296 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
316 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
33 |
Correct |
6 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
81 ms |
6084 KB |
Output is correct |
36 |
Correct |
275 ms |
11408 KB |
Output is correct |
37 |
Correct |
257 ms |
10712 KB |
Output is correct |
38 |
Correct |
1 ms |
308 KB |
Output is correct |
39 |
Correct |
0 ms |
312 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
212 KB |
Output is correct |
44 |
Correct |
1 ms |
212 KB |
Output is correct |
45 |
Correct |
5 ms |
468 KB |
Output is correct |
46 |
Correct |
9 ms |
596 KB |
Output is correct |
47 |
Correct |
1 ms |
340 KB |
Output is correct |
48 |
Correct |
56 ms |
2044 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
212 KB |
Output is correct |
51 |
Correct |
5 ms |
468 KB |
Output is correct |
52 |
Correct |
0 ms |
212 KB |
Output is correct |
53 |
Correct |
1 ms |
212 KB |
Output is correct |
54 |
Correct |
1 ms |
212 KB |
Output is correct |
55 |
Correct |
128 ms |
5504 KB |
Output is correct |
56 |
Correct |
68 ms |
3132 KB |
Output is correct |
57 |
Correct |
60 ms |
3116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
268 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
128 ms |
5544 KB |
Output is correct |
10 |
Correct |
89 ms |
3708 KB |
Output is correct |
11 |
Correct |
71 ms |
2948 KB |
Output is correct |
12 |
Correct |
54 ms |
2296 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
316 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
6 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
81 ms |
6084 KB |
Output is correct |
22 |
Correct |
275 ms |
11408 KB |
Output is correct |
23 |
Correct |
257 ms |
10712 KB |
Output is correct |
24 |
Correct |
53 ms |
1912 KB |
Output is correct |
25 |
Correct |
139 ms |
4880 KB |
Output is correct |
26 |
Correct |
28 ms |
1376 KB |
Output is correct |
27 |
Correct |
262 ms |
10928 KB |
Output is correct |
28 |
Correct |
252 ms |
10764 KB |
Output is correct |
29 |
Correct |
272 ms |
10744 KB |
Output is correct |
30 |
Correct |
282 ms |
10744 KB |
Output is correct |
31 |
Correct |
384 ms |
10764 KB |
Output is correct |
32 |
Correct |
148 ms |
6192 KB |
Output is correct |
33 |
Correct |
359 ms |
11440 KB |
Output is correct |
34 |
Correct |
154 ms |
6084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
316 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
5 ms |
468 KB |
Output is correct |
11 |
Correct |
258 ms |
10736 KB |
Output is correct |
12 |
Correct |
271 ms |
10740 KB |
Output is correct |
13 |
Correct |
189 ms |
8800 KB |
Output is correct |
14 |
Correct |
179 ms |
8792 KB |
Output is correct |
15 |
Correct |
1 ms |
268 KB |
Output is correct |
16 |
Correct |
1 ms |
316 KB |
Output is correct |
17 |
Correct |
1 ms |
312 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
128 ms |
5544 KB |
Output is correct |
24 |
Correct |
89 ms |
3708 KB |
Output is correct |
25 |
Correct |
71 ms |
2948 KB |
Output is correct |
26 |
Correct |
54 ms |
2296 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
316 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
33 |
Correct |
6 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
308 KB |
Output is correct |
35 |
Correct |
0 ms |
312 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
1 ms |
212 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
5 ms |
468 KB |
Output is correct |
42 |
Correct |
9 ms |
596 KB |
Output is correct |
43 |
Correct |
1 ms |
340 KB |
Output is correct |
44 |
Correct |
56 ms |
2044 KB |
Output is correct |
45 |
Correct |
1 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
212 KB |
Output is correct |
47 |
Correct |
5 ms |
468 KB |
Output is correct |
48 |
Correct |
0 ms |
212 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
212 KB |
Output is correct |
51 |
Correct |
128 ms |
5504 KB |
Output is correct |
52 |
Correct |
68 ms |
3132 KB |
Output is correct |
53 |
Correct |
60 ms |
3116 KB |
Output is correct |
54 |
Correct |
53 ms |
1912 KB |
Output is correct |
55 |
Correct |
139 ms |
4880 KB |
Output is correct |
56 |
Correct |
28 ms |
1376 KB |
Output is correct |
57 |
Correct |
262 ms |
10928 KB |
Output is correct |
58 |
Correct |
252 ms |
10764 KB |
Output is correct |
59 |
Correct |
272 ms |
10744 KB |
Output is correct |
60 |
Correct |
282 ms |
10744 KB |
Output is correct |
61 |
Correct |
384 ms |
10764 KB |
Output is correct |
62 |
Correct |
148 ms |
6192 KB |
Output is correct |
63 |
Correct |
359 ms |
11440 KB |
Output is correct |
64 |
Correct |
154 ms |
6084 KB |
Output is correct |
65 |
Correct |
1 ms |
212 KB |
Output is correct |
66 |
Correct |
81 ms |
6084 KB |
Output is correct |
67 |
Correct |
275 ms |
11408 KB |
Output is correct |
68 |
Correct |
257 ms |
10712 KB |
Output is correct |
69 |
Correct |
39 ms |
1356 KB |
Output is correct |
70 |
Correct |
10 ms |
564 KB |
Output is correct |
71 |
Correct |
1 ms |
212 KB |
Output is correct |
72 |
Correct |
54 ms |
1800 KB |
Output is correct |
73 |
Correct |
12 ms |
596 KB |
Output is correct |
74 |
Correct |
1 ms |
340 KB |
Output is correct |
75 |
Correct |
351 ms |
10960 KB |
Output is correct |
76 |
Correct |
274 ms |
10788 KB |
Output is correct |
77 |
Correct |
277 ms |
10756 KB |
Output is correct |
78 |
Correct |
310 ms |
10848 KB |
Output is correct |
79 |
Correct |
362 ms |
10788 KB |
Output is correct |
80 |
Correct |
374 ms |
10796 KB |
Output is correct |
81 |
Correct |
275 ms |
8796 KB |
Output is correct |
82 |
Correct |
283 ms |
8744 KB |
Output is correct |