답안 #886584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886584 2023-12-12T10:42:50 Z dubabuba Self Study (JOI22_ho_t2) C++14
100 / 100
335 ms 13332 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef long long ll;
const int mxn = 3e5 + 10;
const int mxm = 1e9 + 10;
const int inf = 3e18 + 10;
int a[mxn], b[mxn], x[mxn];
int n, m;

void build() {
	for(int i = 0; i < n; i++) {
		a[i] = max(a[i], b[i]);
		x[i] = a[i] * m;
	}
}

int sus(int s, int a) {
	return (s + a - 1) / a;
}

bool can(int MID) {
	int MIN = 0, MAX = 0;
	for(int i = 0; i < n; i++) {
		if(x[i] < MID) MIN += (MID - x[i] + b[i] - 1) / b[i];
		if(x[i] > MID) MAX += min(m, (x[i] - MID) / a[i]);
		MIN = min(MIN, inf);
		MAX = min(MAX, inf);
	}
	return MIN <= MAX;
}

signed main() {
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int j = 0; j < n; j++)
		cin >> b[j];

	build();

	int L = 1e18 + 10, R = 1e18 + 10;
	for(int i = 0; i < n; i++) 
		L = min(L, x[i]);
	while(R - L > 1) {
		int M = (L + R) / 2;
		if(can(M)) L = M;
		else R = M;
	}

	cout << L << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 5 ms 4444 KB Output is correct
11 Correct 268 ms 7452 KB Output is correct
12 Correct 258 ms 7284 KB Output is correct
13 Correct 217 ms 7252 KB Output is correct
14 Correct 270 ms 7328 KB Output is correct
15 Correct 1 ms 4452 KB Output is correct
16 Correct 216 ms 7456 KB Output is correct
17 Correct 273 ms 7496 KB Output is correct
18 Correct 259 ms 7344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4452 KB Output is correct
2 Correct 216 ms 7456 KB Output is correct
3 Correct 273 ms 7496 KB Output is correct
4 Correct 259 ms 7344 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 128 ms 6996 KB Output is correct
14 Correct 90 ms 6748 KB Output is correct
15 Correct 65 ms 6580 KB Output is correct
16 Correct 53 ms 6756 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4536 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4440 KB Output is correct
22 Correct 4 ms 4444 KB Output is correct
23 Correct 5 ms 4552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 5 ms 4444 KB Output is correct
11 Correct 268 ms 7452 KB Output is correct
12 Correct 258 ms 7284 KB Output is correct
13 Correct 217 ms 7252 KB Output is correct
14 Correct 270 ms 7328 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 128 ms 6996 KB Output is correct
24 Correct 90 ms 6748 KB Output is correct
25 Correct 65 ms 6580 KB Output is correct
26 Correct 53 ms 6756 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4536 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4440 KB Output is correct
32 Correct 4 ms 4444 KB Output is correct
33 Correct 5 ms 4552 KB Output is correct
34 Correct 1 ms 4452 KB Output is correct
35 Correct 216 ms 7456 KB Output is correct
36 Correct 273 ms 7496 KB Output is correct
37 Correct 259 ms 7344 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4540 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 1 ms 4536 KB Output is correct
45 Correct 5 ms 4444 KB Output is correct
46 Correct 9 ms 4700 KB Output is correct
47 Correct 2 ms 4444 KB Output is correct
48 Correct 45 ms 7616 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4444 KB Output is correct
51 Correct 5 ms 4552 KB Output is correct
52 Correct 1 ms 4444 KB Output is correct
53 Correct 1 ms 4444 KB Output is correct
54 Correct 1 ms 4444 KB Output is correct
55 Correct 130 ms 9488 KB Output is correct
56 Correct 75 ms 8028 KB Output is correct
57 Correct 91 ms 8016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 128 ms 6996 KB Output is correct
10 Correct 90 ms 6748 KB Output is correct
11 Correct 65 ms 6580 KB Output is correct
12 Correct 53 ms 6756 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4536 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 4 ms 4444 KB Output is correct
19 Correct 5 ms 4552 KB Output is correct
20 Correct 1 ms 4452 KB Output is correct
21 Correct 216 ms 7456 KB Output is correct
22 Correct 273 ms 7496 KB Output is correct
23 Correct 259 ms 7344 KB Output is correct
24 Correct 48 ms 6748 KB Output is correct
25 Correct 135 ms 6752 KB Output is correct
26 Correct 29 ms 6748 KB Output is correct
27 Correct 258 ms 7460 KB Output is correct
28 Correct 263 ms 7248 KB Output is correct
29 Correct 263 ms 7456 KB Output is correct
30 Correct 272 ms 7252 KB Output is correct
31 Correct 335 ms 7332 KB Output is correct
32 Correct 215 ms 7268 KB Output is correct
33 Correct 171 ms 7344 KB Output is correct
34 Correct 221 ms 7248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 5 ms 4444 KB Output is correct
11 Correct 268 ms 7452 KB Output is correct
12 Correct 258 ms 7284 KB Output is correct
13 Correct 217 ms 7252 KB Output is correct
14 Correct 270 ms 7328 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 128 ms 6996 KB Output is correct
24 Correct 90 ms 6748 KB Output is correct
25 Correct 65 ms 6580 KB Output is correct
26 Correct 53 ms 6756 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4536 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4440 KB Output is correct
32 Correct 4 ms 4444 KB Output is correct
33 Correct 5 ms 4552 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 4540 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4536 KB Output is correct
41 Correct 5 ms 4444 KB Output is correct
42 Correct 9 ms 4700 KB Output is correct
43 Correct 2 ms 4444 KB Output is correct
44 Correct 45 ms 7616 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4444 KB Output is correct
47 Correct 5 ms 4552 KB Output is correct
48 Correct 1 ms 4444 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4444 KB Output is correct
51 Correct 130 ms 9488 KB Output is correct
52 Correct 75 ms 8028 KB Output is correct
53 Correct 91 ms 8016 KB Output is correct
54 Correct 48 ms 6748 KB Output is correct
55 Correct 135 ms 6752 KB Output is correct
56 Correct 29 ms 6748 KB Output is correct
57 Correct 258 ms 7460 KB Output is correct
58 Correct 263 ms 7248 KB Output is correct
59 Correct 263 ms 7456 KB Output is correct
60 Correct 272 ms 7252 KB Output is correct
61 Correct 335 ms 7332 KB Output is correct
62 Correct 215 ms 7268 KB Output is correct
63 Correct 171 ms 7344 KB Output is correct
64 Correct 221 ms 7248 KB Output is correct
65 Correct 1 ms 4452 KB Output is correct
66 Correct 216 ms 7456 KB Output is correct
67 Correct 273 ms 7496 KB Output is correct
68 Correct 259 ms 7344 KB Output is correct
69 Correct 33 ms 7248 KB Output is correct
70 Correct 10 ms 4552 KB Output is correct
71 Correct 1 ms 4544 KB Output is correct
72 Correct 46 ms 7588 KB Output is correct
73 Correct 11 ms 4700 KB Output is correct
74 Correct 2 ms 4444 KB Output is correct
75 Correct 266 ms 13332 KB Output is correct
76 Correct 268 ms 13072 KB Output is correct
77 Correct 273 ms 13136 KB Output is correct
78 Correct 286 ms 13136 KB Output is correct
79 Correct 311 ms 13252 KB Output is correct
80 Correct 322 ms 13204 KB Output is correct
81 Correct 120 ms 11112 KB Output is correct
82 Correct 122 ms 11092 KB Output is correct