//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r) {
while (l != r) cout << *l << " ", l++;
cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 300005
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
ll a[maxn], b[maxn];
int main() {
io
ll n, m;
cin >> n >> m;
for (int i = 0;i < n;i++) cin >> a[i];
for (int i = 0;i < n;i++) cin >> b[i];
ll low = 0, up = 1LL<<60;
while (low < up - 1) {
ll mid = (low + up) / 2, cnt = 0;
for (int i = 0;i < n;i++) {
if (b[i] >= a[i]) cnt += (mid + b[i] - 1) / b[i];
else {
if (mid > m * a[i]) cnt += m + (mid - m*a[i] + b[i] - 1) / b[i];
else cnt += (mid + a[i] - 1) / a[i];
}
if (cnt > n * m) break;
}
if (cnt > n * m) up = mid;
else low = mid;
}
cout << low << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 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 |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
396 KB |
Output is correct |
11 |
Correct |
104 ms |
4992 KB |
Output is correct |
12 |
Correct |
100 ms |
4932 KB |
Output is correct |
13 |
Correct |
78 ms |
4964 KB |
Output is correct |
14 |
Correct |
66 ms |
4932 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
29 ms |
4944 KB |
Output is correct |
17 |
Correct |
100 ms |
4876 KB |
Output is correct |
18 |
Correct |
90 ms |
4888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
29 ms |
4944 KB |
Output is correct |
3 |
Correct |
100 ms |
4876 KB |
Output is correct |
4 |
Correct |
90 ms |
4888 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 |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
47 ms |
2600 KB |
Output is correct |
14 |
Correct |
31 ms |
1852 KB |
Output is correct |
15 |
Correct |
23 ms |
1484 KB |
Output is correct |
16 |
Correct |
19 ms |
1264 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
3 ms |
456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 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 |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
396 KB |
Output is correct |
11 |
Correct |
104 ms |
4992 KB |
Output is correct |
12 |
Correct |
100 ms |
4932 KB |
Output is correct |
13 |
Correct |
78 ms |
4964 KB |
Output is correct |
14 |
Correct |
66 ms |
4932 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Correct |
47 ms |
2600 KB |
Output is correct |
24 |
Correct |
31 ms |
1852 KB |
Output is correct |
25 |
Correct |
23 ms |
1484 KB |
Output is correct |
26 |
Correct |
19 ms |
1264 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
0 ms |
204 KB |
Output is correct |
29 |
Correct |
0 ms |
204 KB |
Output is correct |
30 |
Correct |
0 ms |
204 KB |
Output is correct |
31 |
Correct |
0 ms |
204 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
33 |
Correct |
3 ms |
456 KB |
Output is correct |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Correct |
29 ms |
4944 KB |
Output is correct |
36 |
Correct |
100 ms |
4876 KB |
Output is correct |
37 |
Correct |
90 ms |
4888 KB |
Output is correct |
38 |
Correct |
0 ms |
204 KB |
Output is correct |
39 |
Correct |
0 ms |
324 KB |
Output is correct |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
0 ms |
204 KB |
Output is correct |
42 |
Correct |
0 ms |
332 KB |
Output is correct |
43 |
Correct |
0 ms |
204 KB |
Output is correct |
44 |
Correct |
1 ms |
204 KB |
Output is correct |
45 |
Correct |
2 ms |
448 KB |
Output is correct |
46 |
Correct |
4 ms |
588 KB |
Output is correct |
47 |
Correct |
1 ms |
332 KB |
Output is correct |
48 |
Correct |
18 ms |
1612 KB |
Output is correct |
49 |
Correct |
0 ms |
204 KB |
Output is correct |
50 |
Correct |
0 ms |
204 KB |
Output is correct |
51 |
Correct |
2 ms |
332 KB |
Output is correct |
52 |
Correct |
0 ms |
204 KB |
Output is correct |
53 |
Correct |
0 ms |
204 KB |
Output is correct |
54 |
Correct |
0 ms |
316 KB |
Output is correct |
55 |
Correct |
54 ms |
4336 KB |
Output is correct |
56 |
Correct |
32 ms |
2464 KB |
Output is correct |
57 |
Correct |
24 ms |
2488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 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 |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
47 ms |
2600 KB |
Output is correct |
10 |
Correct |
31 ms |
1852 KB |
Output is correct |
11 |
Correct |
23 ms |
1484 KB |
Output is correct |
12 |
Correct |
19 ms |
1264 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
3 ms |
456 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
29 ms |
4944 KB |
Output is correct |
22 |
Correct |
100 ms |
4876 KB |
Output is correct |
23 |
Correct |
90 ms |
4888 KB |
Output is correct |
24 |
Correct |
31 ms |
1280 KB |
Output is correct |
25 |
Correct |
68 ms |
3268 KB |
Output is correct |
26 |
Correct |
12 ms |
908 KB |
Output is correct |
27 |
Correct |
95 ms |
6724 KB |
Output is correct |
28 |
Correct |
100 ms |
6792 KB |
Output is correct |
29 |
Correct |
99 ms |
6700 KB |
Output is correct |
30 |
Correct |
122 ms |
6780 KB |
Output is correct |
31 |
Correct |
206 ms |
7908 KB |
Output is correct |
32 |
Correct |
113 ms |
5584 KB |
Output is correct |
33 |
Correct |
236 ms |
6580 KB |
Output is correct |
34 |
Correct |
113 ms |
5060 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 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 |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
396 KB |
Output is correct |
11 |
Correct |
104 ms |
4992 KB |
Output is correct |
12 |
Correct |
100 ms |
4932 KB |
Output is correct |
13 |
Correct |
78 ms |
4964 KB |
Output is correct |
14 |
Correct |
66 ms |
4932 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Correct |
47 ms |
2600 KB |
Output is correct |
24 |
Correct |
31 ms |
1852 KB |
Output is correct |
25 |
Correct |
23 ms |
1484 KB |
Output is correct |
26 |
Correct |
19 ms |
1264 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
0 ms |
204 KB |
Output is correct |
29 |
Correct |
0 ms |
204 KB |
Output is correct |
30 |
Correct |
0 ms |
204 KB |
Output is correct |
31 |
Correct |
0 ms |
204 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
33 |
Correct |
3 ms |
456 KB |
Output is correct |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Correct |
0 ms |
324 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
0 ms |
204 KB |
Output is correct |
38 |
Correct |
0 ms |
332 KB |
Output is correct |
39 |
Correct |
0 ms |
204 KB |
Output is correct |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
2 ms |
448 KB |
Output is correct |
42 |
Correct |
4 ms |
588 KB |
Output is correct |
43 |
Correct |
1 ms |
332 KB |
Output is correct |
44 |
Correct |
18 ms |
1612 KB |
Output is correct |
45 |
Correct |
0 ms |
204 KB |
Output is correct |
46 |
Correct |
0 ms |
204 KB |
Output is correct |
47 |
Correct |
2 ms |
332 KB |
Output is correct |
48 |
Correct |
0 ms |
204 KB |
Output is correct |
49 |
Correct |
0 ms |
204 KB |
Output is correct |
50 |
Correct |
0 ms |
316 KB |
Output is correct |
51 |
Correct |
54 ms |
4336 KB |
Output is correct |
52 |
Correct |
32 ms |
2464 KB |
Output is correct |
53 |
Correct |
24 ms |
2488 KB |
Output is correct |
54 |
Correct |
31 ms |
1280 KB |
Output is correct |
55 |
Correct |
68 ms |
3268 KB |
Output is correct |
56 |
Correct |
12 ms |
908 KB |
Output is correct |
57 |
Correct |
95 ms |
6724 KB |
Output is correct |
58 |
Correct |
100 ms |
6792 KB |
Output is correct |
59 |
Correct |
99 ms |
6700 KB |
Output is correct |
60 |
Correct |
122 ms |
6780 KB |
Output is correct |
61 |
Correct |
206 ms |
7908 KB |
Output is correct |
62 |
Correct |
113 ms |
5584 KB |
Output is correct |
63 |
Correct |
236 ms |
6580 KB |
Output is correct |
64 |
Correct |
113 ms |
5060 KB |
Output is correct |
65 |
Correct |
0 ms |
204 KB |
Output is correct |
66 |
Correct |
29 ms |
4944 KB |
Output is correct |
67 |
Correct |
100 ms |
4876 KB |
Output is correct |
68 |
Correct |
90 ms |
4888 KB |
Output is correct |
69 |
Correct |
20 ms |
900 KB |
Output is correct |
70 |
Correct |
6 ms |
332 KB |
Output is correct |
71 |
Correct |
0 ms |
204 KB |
Output is correct |
72 |
Correct |
32 ms |
1228 KB |
Output is correct |
73 |
Correct |
6 ms |
460 KB |
Output is correct |
74 |
Correct |
1 ms |
344 KB |
Output is correct |
75 |
Correct |
111 ms |
7016 KB |
Output is correct |
76 |
Correct |
115 ms |
6760 KB |
Output is correct |
77 |
Correct |
123 ms |
6152 KB |
Output is correct |
78 |
Correct |
151 ms |
5232 KB |
Output is correct |
79 |
Correct |
205 ms |
6728 KB |
Output is correct |
80 |
Correct |
216 ms |
9552 KB |
Output is correct |
81 |
Correct |
217 ms |
6428 KB |
Output is correct |
82 |
Correct |
164 ms |
6852 KB |
Output is correct |