답안 #526437

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
526437 2022-02-14T18:41:09 Z sidon Self Study (JOI22_ho_t2) C++17
100 / 100
388 ms 6556 KB
#include <bits/stdc++.h>
using namespace std;
#define int __int128
#define i64 int64_t

const int Z = 3e5, INF = 1e18;

i64 N, M, A[Z], B[Z];

int32_t main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> N >> M;

	for(int i = 0; i < N; ++i) cin >> A[i];
	for(int i = 0; i < N; ++i) cin >> B[i];

	for(int i = 0; i < N; ++i)
		A[i] = max(A[i], B[i]);

	int ans = 0;

	for(int add = 1LL<<62; add /= 2; ) {
		int x = ans + add;

		int free = 0;

		for(int i = 0; i < N; ++i) {
			int a_req = (x + A[i] - 1) / A[i];

			if(a_req <= M)
				free += M - a_req;
			else {
				int req = x - M * A[i];

				int b_req = (req + B[i] - 1) / B[i];
				free -= b_req;
			}
		}

		if(free >= 0) ans += add;
	}

	cout << (int64_t)ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 216 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 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 4 ms 472 KB Output is correct
11 Correct 239 ms 6396 KB Output is correct
12 Correct 241 ms 6464 KB Output is correct
13 Correct 258 ms 6556 KB Output is correct
14 Correct 305 ms 6460 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 372 ms 5228 KB Output is correct
17 Correct 275 ms 5764 KB Output is correct
18 Correct 241 ms 6096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 372 ms 5228 KB Output is correct
3 Correct 275 ms 5764 KB Output is correct
4 Correct 241 ms 6096 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 0 ms 332 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 127 ms 4188 KB Output is correct
14 Correct 84 ms 2696 KB Output is correct
15 Correct 61 ms 2148 KB Output is correct
16 Correct 51 ms 1772 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 7 ms 364 KB Output is correct
23 Correct 5 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 216 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 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 4 ms 472 KB Output is correct
11 Correct 239 ms 6396 KB Output is correct
12 Correct 241 ms 6464 KB Output is correct
13 Correct 258 ms 6556 KB Output is correct
14 Correct 305 ms 6460 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 0 ms 332 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 127 ms 4188 KB Output is correct
24 Correct 84 ms 2696 KB Output is correct
25 Correct 61 ms 2148 KB Output is correct
26 Correct 51 ms 1772 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 7 ms 364 KB Output is correct
33 Correct 5 ms 468 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 372 ms 5228 KB Output is correct
36 Correct 275 ms 5764 KB Output is correct
37 Correct 241 ms 6096 KB Output is correct
38 Correct 0 ms 332 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 5 ms 460 KB Output is correct
46 Correct 8 ms 496 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 47 ms 1792 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 0 ms 204 KB Output is correct
51 Correct 5 ms 388 KB Output is correct
52 Correct 0 ms 204 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 0 ms 204 KB Output is correct
55 Correct 127 ms 4004 KB Output is correct
56 Correct 85 ms 2432 KB Output is correct
57 Correct 105 ms 2508 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 0 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 127 ms 4188 KB Output is correct
10 Correct 84 ms 2696 KB Output is correct
11 Correct 61 ms 2148 KB Output is correct
12 Correct 51 ms 1772 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 7 ms 364 KB Output is correct
19 Correct 5 ms 468 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 372 ms 5228 KB Output is correct
22 Correct 275 ms 5764 KB Output is correct
23 Correct 241 ms 6096 KB Output is correct
24 Correct 42 ms 1480 KB Output is correct
25 Correct 118 ms 3268 KB Output is correct
26 Correct 27 ms 1004 KB Output is correct
27 Correct 242 ms 6468 KB Output is correct
28 Correct 260 ms 6344 KB Output is correct
29 Correct 247 ms 6464 KB Output is correct
30 Correct 254 ms 6372 KB Output is correct
31 Correct 252 ms 6468 KB Output is correct
32 Correct 369 ms 5596 KB Output is correct
33 Correct 308 ms 6448 KB Output is correct
34 Correct 388 ms 5052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 216 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 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 4 ms 472 KB Output is correct
11 Correct 239 ms 6396 KB Output is correct
12 Correct 241 ms 6464 KB Output is correct
13 Correct 258 ms 6556 KB Output is correct
14 Correct 305 ms 6460 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 0 ms 332 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 127 ms 4188 KB Output is correct
24 Correct 84 ms 2696 KB Output is correct
25 Correct 61 ms 2148 KB Output is correct
26 Correct 51 ms 1772 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 7 ms 364 KB Output is correct
33 Correct 5 ms 468 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 5 ms 460 KB Output is correct
42 Correct 8 ms 496 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 47 ms 1792 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 5 ms 388 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 0 ms 204 KB Output is correct
51 Correct 127 ms 4004 KB Output is correct
52 Correct 85 ms 2432 KB Output is correct
53 Correct 105 ms 2508 KB Output is correct
54 Correct 42 ms 1480 KB Output is correct
55 Correct 118 ms 3268 KB Output is correct
56 Correct 27 ms 1004 KB Output is correct
57 Correct 242 ms 6468 KB Output is correct
58 Correct 260 ms 6344 KB Output is correct
59 Correct 247 ms 6464 KB Output is correct
60 Correct 254 ms 6372 KB Output is correct
61 Correct 252 ms 6468 KB Output is correct
62 Correct 369 ms 5596 KB Output is correct
63 Correct 308 ms 6448 KB Output is correct
64 Correct 388 ms 5052 KB Output is correct
65 Correct 0 ms 204 KB Output is correct
66 Correct 372 ms 5228 KB Output is correct
67 Correct 275 ms 5764 KB Output is correct
68 Correct 241 ms 6096 KB Output is correct
69 Correct 30 ms 1012 KB Output is correct
70 Correct 7 ms 448 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 38 ms 1232 KB Output is correct
73 Correct 10 ms 588 KB Output is correct
74 Correct 1 ms 332 KB Output is correct
75 Correct 256 ms 6488 KB Output is correct
76 Correct 249 ms 6524 KB Output is correct
77 Correct 257 ms 6152 KB Output is correct
78 Correct 258 ms 5188 KB Output is correct
79 Correct 270 ms 6484 KB Output is correct
80 Correct 264 ms 6372 KB Output is correct
81 Correct 291 ms 6452 KB Output is correct
82 Correct 319 ms 6464 KB Output is correct