Submission #969204

# Submission time Handle Problem Language Result Execution time Memory
969204 2024-04-24T16:29:16 Z yellowtoad Self Study (JOI22_ho_t2) C++17
100 / 100
391 ms 11348 KB
#include <iostream>
#include <algorithm>
#define f first
#define s second
using namespace std;

long long n, m, a[300010], b[300010], ans;
__int128 l = 0, r = 1e20, mid, cnt, req;

bool check() {
	cnt = req = 0;
	for (int i = 1; i <= n; i++) {
		if (b[i] > a[i]) {
			cnt += m;
			req += (mid+b[i]-1)/b[i];
		} else {
			if (a[i]*m >= mid) cnt += (a[i]*m-mid)/a[i];
			else req += (mid-a[i]*m+b[i]-1)/b[i];
		}
	}
	if (cnt < req) return 0;
	else return 1;
}

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];
	while (l <= r) {
		mid = (l+r)/2;
		if (!check()) r = mid-1;
		else l = mid+1;
	}
	ans = r;
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 330 ms 5028 KB Output is correct
12 Correct 326 ms 5108 KB Output is correct
13 Correct 237 ms 5200 KB Output is correct
14 Correct 301 ms 5104 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 246 ms 4944 KB Output is correct
17 Correct 303 ms 5112 KB Output is correct
18 Correct 280 ms 5112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 246 ms 4944 KB Output is correct
3 Correct 303 ms 5112 KB Output is correct
4 Correct 280 ms 5112 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 144 ms 4692 KB Output is correct
14 Correct 116 ms 4688 KB Output is correct
15 Correct 71 ms 4696 KB Output is correct
16 Correct 58 ms 4528 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 5 ms 2396 KB Output is correct
23 Correct 5 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 330 ms 5028 KB Output is correct
12 Correct 326 ms 5108 KB Output is correct
13 Correct 237 ms 5200 KB Output is correct
14 Correct 301 ms 5104 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 144 ms 4692 KB Output is correct
24 Correct 116 ms 4688 KB Output is correct
25 Correct 71 ms 4696 KB Output is correct
26 Correct 58 ms 4528 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 5 ms 2396 KB Output is correct
33 Correct 5 ms 2396 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 246 ms 4944 KB Output is correct
36 Correct 303 ms 5112 KB Output is correct
37 Correct 280 ms 5112 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2392 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 6 ms 2396 KB Output is correct
46 Correct 10 ms 2904 KB Output is correct
47 Correct 2 ms 2396 KB Output is correct
48 Correct 58 ms 5696 KB Output is correct
49 Correct 1 ms 2392 KB Output is correct
50 Correct 1 ms 2392 KB Output is correct
51 Correct 6 ms 2396 KB Output is correct
52 Correct 1 ms 2408 KB Output is correct
53 Correct 1 ms 2396 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 204 ms 7508 KB Output is correct
56 Correct 86 ms 5980 KB Output is correct
57 Correct 98 ms 5796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 144 ms 4692 KB Output is correct
10 Correct 116 ms 4688 KB Output is correct
11 Correct 71 ms 4696 KB Output is correct
12 Correct 58 ms 4528 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 5 ms 2396 KB Output is correct
19 Correct 5 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 246 ms 4944 KB Output is correct
22 Correct 303 ms 5112 KB Output is correct
23 Correct 280 ms 5112 KB Output is correct
24 Correct 50 ms 5456 KB Output is correct
25 Correct 144 ms 7248 KB Output is correct
26 Correct 31 ms 5208 KB Output is correct
27 Correct 282 ms 11068 KB Output is correct
28 Correct 288 ms 10832 KB Output is correct
29 Correct 289 ms 10920 KB Output is correct
30 Correct 336 ms 10924 KB Output is correct
31 Correct 351 ms 10920 KB Output is correct
32 Correct 244 ms 6224 KB Output is correct
33 Correct 287 ms 11348 KB Output is correct
34 Correct 253 ms 6548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 330 ms 5028 KB Output is correct
12 Correct 326 ms 5108 KB Output is correct
13 Correct 237 ms 5200 KB Output is correct
14 Correct 301 ms 5104 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 144 ms 4692 KB Output is correct
24 Correct 116 ms 4688 KB Output is correct
25 Correct 71 ms 4696 KB Output is correct
26 Correct 58 ms 4528 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 5 ms 2396 KB Output is correct
33 Correct 5 ms 2396 KB Output is correct
34 Correct 0 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2392 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 6 ms 2396 KB Output is correct
42 Correct 10 ms 2904 KB Output is correct
43 Correct 2 ms 2396 KB Output is correct
44 Correct 58 ms 5696 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 6 ms 2396 KB Output is correct
48 Correct 1 ms 2408 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 204 ms 7508 KB Output is correct
52 Correct 86 ms 5980 KB Output is correct
53 Correct 98 ms 5796 KB Output is correct
54 Correct 50 ms 5456 KB Output is correct
55 Correct 144 ms 7248 KB Output is correct
56 Correct 31 ms 5208 KB Output is correct
57 Correct 282 ms 11068 KB Output is correct
58 Correct 288 ms 10832 KB Output is correct
59 Correct 289 ms 10920 KB Output is correct
60 Correct 336 ms 10924 KB Output is correct
61 Correct 351 ms 10920 KB Output is correct
62 Correct 244 ms 6224 KB Output is correct
63 Correct 287 ms 11348 KB Output is correct
64 Correct 253 ms 6548 KB Output is correct
65 Correct 1 ms 2392 KB Output is correct
66 Correct 246 ms 4944 KB Output is correct
67 Correct 303 ms 5112 KB Output is correct
68 Correct 280 ms 5112 KB Output is correct
69 Correct 37 ms 5212 KB Output is correct
70 Correct 9 ms 2652 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 49 ms 5548 KB Output is correct
73 Correct 12 ms 2652 KB Output is correct
74 Correct 2 ms 2396 KB Output is correct
75 Correct 337 ms 10848 KB Output is correct
76 Correct 334 ms 10916 KB Output is correct
77 Correct 364 ms 10920 KB Output is correct
78 Correct 391 ms 10792 KB Output is correct
79 Correct 336 ms 10836 KB Output is correct
80 Correct 337 ms 10792 KB Output is correct
81 Correct 306 ms 8928 KB Output is correct
82 Correct 280 ms 8788 KB Output is correct