Submission #864793

# Submission time Handle Problem Language Result Execution time Memory
864793 2023-10-23T15:40:56 Z serifefedartar Self Study (JOI22_ho_t2) C++17
100 / 100
200 ms 11408 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll LOGN = 20; 
const ll MAXN = 3e5 + 100;

vector<ll> A, B;
ll N, M;
bool check(ll x) {
	ll need = 0;
	for (int i = 1; i <= N; i++) {
		if (M * A[i] >= x)
			need += (x + A[i] - 1) / A[i];
		else
			need += M + (x - A[i] * M + B[i] - 1) / B[i];
		if (need > N * M)
			return false;
	}
	return (need <= N * M);
}

int main() {
	fast
	cin >> N >> M;

	A = vector<ll>(N+1);
	B = vector<ll>(N+1);
	for (int i = 1; i <= N; i++)
		cin >> A[i];
	for (int i = 1; i <= N; i++)
		cin >> B[i];
	for (int i = 1; i <= N; i++)
		A[i] = max(A[i], B[i]);

	ll L = 0;
	ll R = 2 * 1e18;
	ll ans = -1;
	while (L <= R) {
		ll mid = L + (R-L)/2;
		if (check(mid)) {
			L = mid + 1;
			ans = mid;
		} else
			R = mid - 1;
	}
	cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 500 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 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 82 ms 4956 KB Output is correct
12 Correct 86 ms 4956 KB Output is correct
13 Correct 66 ms 4956 KB Output is correct
14 Correct 56 ms 4956 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 33 ms 6304 KB Output is correct
17 Correct 79 ms 11344 KB Output is correct
18 Correct 81 ms 10832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 33 ms 6304 KB Output is correct
3 Correct 79 ms 11344 KB Output is correct
4 Correct 81 ms 10832 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 368 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 44 ms 2652 KB Output is correct
14 Correct 28 ms 1884 KB Output is correct
15 Correct 20 ms 1628 KB Output is correct
16 Correct 21 ms 1372 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 500 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 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 82 ms 4956 KB Output is correct
12 Correct 86 ms 4956 KB Output is correct
13 Correct 66 ms 4956 KB Output is correct
14 Correct 56 ms 4956 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 368 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 44 ms 2652 KB Output is correct
24 Correct 28 ms 1884 KB Output is correct
25 Correct 20 ms 1628 KB Output is correct
26 Correct 21 ms 1372 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 3 ms 604 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 33 ms 6304 KB Output is correct
36 Correct 79 ms 11344 KB Output is correct
37 Correct 81 ms 10832 KB Output is correct
38 Correct 1 ms 600 KB Output is correct
39 Correct 0 ms 460 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 1 ms 348 KB Output is correct
44 Correct 0 ms 388 KB Output is correct
45 Correct 2 ms 1016 KB Output is correct
46 Correct 3 ms 604 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 16 ms 2140 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
52 Correct 0 ms 604 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 42 ms 5720 KB Output is correct
56 Correct 31 ms 3416 KB Output is correct
57 Correct 21 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 368 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 44 ms 2652 KB Output is correct
10 Correct 28 ms 1884 KB Output is correct
11 Correct 20 ms 1628 KB Output is correct
12 Correct 21 ms 1372 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 33 ms 6304 KB Output is correct
22 Correct 79 ms 11344 KB Output is correct
23 Correct 81 ms 10832 KB Output is correct
24 Correct 27 ms 2068 KB Output is correct
25 Correct 64 ms 5124 KB Output is correct
26 Correct 13 ms 1368 KB Output is correct
27 Correct 96 ms 10776 KB Output is correct
28 Correct 86 ms 10816 KB Output is correct
29 Correct 106 ms 10932 KB Output is correct
30 Correct 109 ms 10884 KB Output is correct
31 Correct 200 ms 10944 KB Output is correct
32 Correct 102 ms 6168 KB Output is correct
33 Correct 144 ms 11408 KB Output is correct
34 Correct 90 ms 6316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 500 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 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 82 ms 4956 KB Output is correct
12 Correct 86 ms 4956 KB Output is correct
13 Correct 66 ms 4956 KB Output is correct
14 Correct 56 ms 4956 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 368 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 44 ms 2652 KB Output is correct
24 Correct 28 ms 1884 KB Output is correct
25 Correct 20 ms 1628 KB Output is correct
26 Correct 21 ms 1372 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 3 ms 604 KB Output is correct
34 Correct 1 ms 600 KB Output is correct
35 Correct 0 ms 460 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 1 ms 348 KB Output is correct
40 Correct 0 ms 388 KB Output is correct
41 Correct 2 ms 1016 KB Output is correct
42 Correct 3 ms 604 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 16 ms 2140 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 2 ms 604 KB Output is correct
48 Correct 0 ms 604 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 42 ms 5720 KB Output is correct
52 Correct 31 ms 3416 KB Output is correct
53 Correct 21 ms 3164 KB Output is correct
54 Correct 27 ms 2068 KB Output is correct
55 Correct 64 ms 5124 KB Output is correct
56 Correct 13 ms 1368 KB Output is correct
57 Correct 96 ms 10776 KB Output is correct
58 Correct 86 ms 10816 KB Output is correct
59 Correct 106 ms 10932 KB Output is correct
60 Correct 109 ms 10884 KB Output is correct
61 Correct 200 ms 10944 KB Output is correct
62 Correct 102 ms 6168 KB Output is correct
63 Correct 144 ms 11408 KB Output is correct
64 Correct 90 ms 6316 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 33 ms 6304 KB Output is correct
67 Correct 79 ms 11344 KB Output is correct
68 Correct 81 ms 10832 KB Output is correct
69 Correct 19 ms 1372 KB Output is correct
70 Correct 5 ms 604 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 28 ms 1980 KB Output is correct
73 Correct 6 ms 860 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 97 ms 10888 KB Output is correct
76 Correct 107 ms 10884 KB Output is correct
77 Correct 111 ms 11012 KB Output is correct
78 Correct 139 ms 10940 KB Output is correct
79 Correct 187 ms 10880 KB Output is correct
80 Correct 200 ms 11040 KB Output is correct
81 Correct 132 ms 8832 KB Output is correct
82 Correct 96 ms 8836 KB Output is correct