Submission #937836

# Submission time Handle Problem Language Result Execution time Memory
937836 2024-03-04T15:08:40 Z vjudge1 Self Study (JOI22_ho_t2) C++17
100 / 100
216 ms 11476 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	long long N, M; cin >> N >> M;
	vector<int> A(N);
	for(auto &i : A) cin >> i;
	vector<int> B(N);
	for(auto &i : B) cin >> i;
	long long lo = 0;
	long long hi = 1e18;
	long long bst = 0;
	while(lo <= hi){
		long long mid = (lo + hi) / 2;
		long long need = 0;
		for(int i = 0; i < N && need <= N * M; i++){
			long long needClass = (mid + max(A[i], B[i]) - 1) / max(A[i], B[i]);
			if(needClass <= M){
				need += needClass;
				continue;
			}
			need += M;
			long long left = mid - max(A[i], B[i]) * M;
			need += (left + B[i] - 1) / B[i];
		}
		if(need <= N*M){
			bst = mid;
			lo = mid + 1;
		}else hi = mid - 1;
	}
	// int bst = 2e9;
	// for(int i = 0; i < N; i++) bst = min(bst, max(A[i], B[i]));
	cout << bst << "\n";
}
# 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 1 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 2 ms 348 KB Output is correct
11 Correct 81 ms 4956 KB Output is correct
12 Correct 81 ms 4952 KB Output is correct
13 Correct 77 ms 5376 KB Output is correct
14 Correct 57 ms 4944 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 28 ms 5116 KB Output is correct
17 Correct 89 ms 4956 KB Output is correct
18 Correct 81 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 28 ms 5116 KB Output is correct
3 Correct 89 ms 4956 KB Output is correct
4 Correct 81 ms 4956 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 504 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 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 456 KB Output is correct
13 Correct 44 ms 5460 KB Output is correct
14 Correct 34 ms 3928 KB Output is correct
15 Correct 21 ms 2908 KB Output is correct
16 Correct 20 ms 2392 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 3 ms 600 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 1 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 2 ms 348 KB Output is correct
11 Correct 81 ms 4956 KB Output is correct
12 Correct 81 ms 4952 KB Output is correct
13 Correct 77 ms 5376 KB Output is correct
14 Correct 57 ms 4944 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 504 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 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 456 KB Output is correct
23 Correct 44 ms 5460 KB Output is correct
24 Correct 34 ms 3928 KB Output is correct
25 Correct 21 ms 2908 KB Output is correct
26 Correct 20 ms 2392 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 3 ms 600 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 28 ms 5116 KB Output is correct
36 Correct 89 ms 4956 KB Output is correct
37 Correct 81 ms 4956 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 352 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 344 KB Output is correct
45 Correct 2 ms 600 KB Output is correct
46 Correct 3 ms 604 KB Output is correct
47 Correct 1 ms 472 KB Output is correct
48 Correct 17 ms 2268 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 452 KB Output is correct
51 Correct 2 ms 580 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 0 ms 452 KB Output is correct
55 Correct 46 ms 5644 KB Output is correct
56 Correct 31 ms 3164 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 504 KB Output is correct
4 Correct 0 ms 344 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 456 KB Output is correct
9 Correct 44 ms 5460 KB Output is correct
10 Correct 34 ms 3928 KB Output is correct
11 Correct 21 ms 2908 KB Output is correct
12 Correct 20 ms 2392 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 3 ms 600 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 28 ms 5116 KB Output is correct
22 Correct 89 ms 4956 KB Output is correct
23 Correct 81 ms 4956 KB Output is correct
24 Correct 29 ms 1884 KB Output is correct
25 Correct 71 ms 4944 KB Output is correct
26 Correct 12 ms 1440 KB Output is correct
27 Correct 81 ms 10880 KB Output is correct
28 Correct 92 ms 10832 KB Output is correct
29 Correct 102 ms 11088 KB Output is correct
30 Correct 119 ms 10932 KB Output is correct
31 Correct 190 ms 10836 KB Output is correct
32 Correct 136 ms 6236 KB Output is correct
33 Correct 208 ms 11476 KB Output is correct
34 Correct 153 ms 6236 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 1 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 2 ms 348 KB Output is correct
11 Correct 81 ms 4956 KB Output is correct
12 Correct 81 ms 4952 KB Output is correct
13 Correct 77 ms 5376 KB Output is correct
14 Correct 57 ms 4944 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 504 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 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 456 KB Output is correct
23 Correct 44 ms 5460 KB Output is correct
24 Correct 34 ms 3928 KB Output is correct
25 Correct 21 ms 2908 KB Output is correct
26 Correct 20 ms 2392 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 3 ms 600 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 352 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 344 KB Output is correct
41 Correct 2 ms 600 KB Output is correct
42 Correct 3 ms 604 KB Output is correct
43 Correct 1 ms 472 KB Output is correct
44 Correct 17 ms 2268 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 452 KB Output is correct
47 Correct 2 ms 580 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 0 ms 452 KB Output is correct
51 Correct 46 ms 5644 KB Output is correct
52 Correct 31 ms 3164 KB Output is correct
53 Correct 21 ms 3164 KB Output is correct
54 Correct 29 ms 1884 KB Output is correct
55 Correct 71 ms 4944 KB Output is correct
56 Correct 12 ms 1440 KB Output is correct
57 Correct 81 ms 10880 KB Output is correct
58 Correct 92 ms 10832 KB Output is correct
59 Correct 102 ms 11088 KB Output is correct
60 Correct 119 ms 10932 KB Output is correct
61 Correct 190 ms 10836 KB Output is correct
62 Correct 136 ms 6236 KB Output is correct
63 Correct 208 ms 11476 KB Output is correct
64 Correct 153 ms 6236 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 28 ms 5116 KB Output is correct
67 Correct 89 ms 4956 KB Output is correct
68 Correct 81 ms 4956 KB Output is correct
69 Correct 21 ms 1372 KB Output is correct
70 Correct 6 ms 604 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 31 ms 1980 KB Output is correct
73 Correct 7 ms 600 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 103 ms 10932 KB Output is correct
76 Correct 116 ms 10932 KB Output is correct
77 Correct 125 ms 10832 KB Output is correct
78 Correct 160 ms 11012 KB Output is correct
79 Correct 214 ms 10832 KB Output is correct
80 Correct 216 ms 10732 KB Output is correct
81 Correct 197 ms 8956 KB Output is correct
82 Correct 195 ms 8944 KB Output is correct