Submission #1033235

# Submission time Handle Problem Language Result Execution time Memory
1033235 2024-07-24T14:47:31 Z juicy Self Study (JOI22_ho_t2) C++17
100 / 100
134 ms 9068 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	int N, M; cin >> N >> M;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < N; ++i) {
		cin >> B[i];
	}
	auto check = [&](long long K) -> bool {
		long long cnt = 0;
		for (int i = 0; i < N; ++i) {
			auto X = K;
			if (A[i] > B[i]) {
				int dec = min((long long) M, (X - 1) / A[i] + 1);
				X -= (long long) dec * A[i];
				cnt += dec;
			}
			if (X > 0) {
				cnt += (X - 1) / B[i] + 1;
			}
			if (cnt > (long long) N * M) {
				return 0;
			}
		}
		return 1;
	};
	long long L = 1, R = 1e18, res = 0;
	while (L <= R) {
		auto md = (L + R) / 2;
		if (check(md)) {
			res = md;
			L = md + 1;
		} else {
			R = md - 1;
		}
	}
	cout << res;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 79 ms 8552 KB Output is correct
12 Correct 86 ms 8532 KB Output is correct
13 Correct 47 ms 6512 KB Output is correct
14 Correct 43 ms 6616 KB Output is correct
15 Correct 0 ms 448 KB Output is correct
16 Correct 21 ms 3824 KB Output is correct
17 Correct 58 ms 9040 KB Output is correct
18 Correct 66 ms 8532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 448 KB Output is correct
2 Correct 21 ms 3824 KB Output is correct
3 Correct 58 ms 9040 KB Output is correct
4 Correct 66 ms 8532 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 452 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 30 ms 4316 KB Output is correct
14 Correct 19 ms 3164 KB Output is correct
15 Correct 15 ms 2396 KB Output is correct
16 Correct 13 ms 1884 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 79 ms 8552 KB Output is correct
12 Correct 86 ms 8532 KB Output is correct
13 Correct 47 ms 6512 KB Output is correct
14 Correct 43 ms 6616 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 452 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 30 ms 4316 KB Output is correct
24 Correct 19 ms 3164 KB Output is correct
25 Correct 15 ms 2396 KB Output is correct
26 Correct 13 ms 1884 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 0 ms 448 KB Output is correct
35 Correct 21 ms 3824 KB Output is correct
36 Correct 58 ms 9040 KB Output is correct
37 Correct 66 ms 8532 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 464 KB Output is correct
46 Correct 3 ms 604 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 15 ms 1628 KB Output is correct
49 Correct 0 ms 460 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 44 ms 4312 KB Output is correct
56 Correct 18 ms 2396 KB Output is correct
57 Correct 15 ms 2520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 452 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 30 ms 4316 KB Output is correct
10 Correct 19 ms 3164 KB Output is correct
11 Correct 15 ms 2396 KB Output is correct
12 Correct 13 ms 1884 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 0 ms 448 KB Output is correct
21 Correct 21 ms 3824 KB Output is correct
22 Correct 58 ms 9040 KB Output is correct
23 Correct 66 ms 8532 KB Output is correct
24 Correct 12 ms 1628 KB Output is correct
25 Correct 32 ms 3948 KB Output is correct
26 Correct 7 ms 1116 KB Output is correct
27 Correct 59 ms 8424 KB Output is correct
28 Correct 63 ms 8792 KB Output is correct
29 Correct 63 ms 8528 KB Output is correct
30 Correct 65 ms 8440 KB Output is correct
31 Correct 77 ms 8532 KB Output is correct
32 Correct 42 ms 3932 KB Output is correct
33 Correct 83 ms 9068 KB Output is correct
34 Correct 42 ms 3944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 79 ms 8552 KB Output is correct
12 Correct 86 ms 8532 KB Output is correct
13 Correct 47 ms 6512 KB Output is correct
14 Correct 43 ms 6616 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 452 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 30 ms 4316 KB Output is correct
24 Correct 19 ms 3164 KB Output is correct
25 Correct 15 ms 2396 KB Output is correct
26 Correct 13 ms 1884 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 464 KB Output is correct
42 Correct 3 ms 604 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 15 ms 1628 KB Output is correct
45 Correct 0 ms 460 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 44 ms 4312 KB Output is correct
52 Correct 18 ms 2396 KB Output is correct
53 Correct 15 ms 2520 KB Output is correct
54 Correct 12 ms 1628 KB Output is correct
55 Correct 32 ms 3948 KB Output is correct
56 Correct 7 ms 1116 KB Output is correct
57 Correct 59 ms 8424 KB Output is correct
58 Correct 63 ms 8792 KB Output is correct
59 Correct 63 ms 8528 KB Output is correct
60 Correct 65 ms 8440 KB Output is correct
61 Correct 77 ms 8532 KB Output is correct
62 Correct 42 ms 3932 KB Output is correct
63 Correct 83 ms 9068 KB Output is correct
64 Correct 42 ms 3944 KB Output is correct
65 Correct 0 ms 448 KB Output is correct
66 Correct 21 ms 3824 KB Output is correct
67 Correct 58 ms 9040 KB Output is correct
68 Correct 66 ms 8532 KB Output is correct
69 Correct 13 ms 1112 KB Output is correct
70 Correct 3 ms 604 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 19 ms 1640 KB Output is correct
73 Correct 3 ms 600 KB Output is correct
74 Correct 1 ms 344 KB Output is correct
75 Correct 89 ms 8552 KB Output is correct
76 Correct 98 ms 8608 KB Output is correct
77 Correct 101 ms 8532 KB Output is correct
78 Correct 116 ms 8532 KB Output is correct
79 Correct 131 ms 8532 KB Output is correct
80 Correct 134 ms 8528 KB Output is correct
81 Correct 73 ms 6484 KB Output is correct
82 Correct 74 ms 6516 KB Output is correct