Submission #1018827

# Submission time Handle Problem Language Result Execution time Memory
1018827 2024-07-10T10:04:08 Z vjudge1 Self Study (JOI22_ho_t2) C++17
100 / 100
228 ms 5120 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n, m;
	cin >> n >> m;
	vector <int> a(n), b(n);
	int mx = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	auto check = [&](int p) {
		int t = 0;
		for (int i = 0; i < n; i++) {
			if (b[i] > a[i]) {
				int B = (p + b[i] -1) / b[i];
				t += B;
			} else {
				if (a[i] * 1ll * m >= p) {
					int A = (p + a[i] - 1) / a[i];
					t += A;
				} else {
					int A = m;
					int B = (p - a[i] * 1ll * A + b[i] -1) / b[i];
					t += A + B;
				}
			}
			if(t > n * 1ll * m) return false;
		}
		if(t <= n * 1ll * m) return true;
		else return false;
	};
	int l = 0, r = 1e18 + 5;
	while (r - l > 1) {
		int mid = (l + r) >> 1;
		if (check(mid)) {
			l = mid;
		} else {
			r = mid;
		}
	}
	if(check(r)) cout << r <<"\n";
	else cout << l << "\n";
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:8:6: warning: unused variable 'mx' [-Wunused-variable]
    8 |  int mx = 0;
      |      ^~
# Verdict Execution time Memory Grader output
1 Correct 1 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 344 KB Output is correct
6 Correct 0 ms 344 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 344 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 214 ms 4956 KB Output is correct
12 Correct 189 ms 4952 KB Output is correct
13 Correct 129 ms 4956 KB Output is correct
14 Correct 122 ms 4956 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 70 ms 4952 KB Output is correct
17 Correct 154 ms 4952 KB Output is correct
18 Correct 158 ms 5120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 70 ms 4952 KB Output is correct
3 Correct 154 ms 4952 KB Output is correct
4 Correct 158 ms 5120 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 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 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 82 ms 2652 KB Output is correct
14 Correct 66 ms 1988 KB Output is correct
15 Correct 40 ms 1368 KB Output is correct
16 Correct 33 ms 1372 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 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 1 ms 348 KB Output is correct
23 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 344 KB Output is correct
6 Correct 0 ms 344 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 344 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 214 ms 4956 KB Output is correct
12 Correct 189 ms 4952 KB Output is correct
13 Correct 129 ms 4956 KB Output is correct
14 Correct 122 ms 4956 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 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 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 348 KB Output is correct
23 Correct 82 ms 2652 KB Output is correct
24 Correct 66 ms 1988 KB Output is correct
25 Correct 40 ms 1368 KB Output is correct
26 Correct 33 ms 1372 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 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 3 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 70 ms 4952 KB Output is correct
36 Correct 154 ms 4952 KB Output is correct
37 Correct 158 ms 5120 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 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 3 ms 348 KB Output is correct
46 Correct 5 ms 576 KB Output is correct
47 Correct 2 ms 348 KB Output is correct
48 Correct 32 ms 1256 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 3 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 93 ms 2752 KB Output is correct
56 Correct 151 ms 1880 KB Output is correct
57 Correct 41 ms 1880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 82 ms 2652 KB Output is correct
10 Correct 66 ms 1988 KB Output is correct
11 Correct 40 ms 1368 KB Output is correct
12 Correct 33 ms 1372 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 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 3 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 70 ms 4952 KB Output is correct
22 Correct 154 ms 4952 KB Output is correct
23 Correct 158 ms 5120 KB Output is correct
24 Correct 28 ms 1116 KB Output is correct
25 Correct 81 ms 2396 KB Output is correct
26 Correct 17 ms 856 KB Output is correct
27 Correct 154 ms 4952 KB Output is correct
28 Correct 168 ms 4956 KB Output is correct
29 Correct 161 ms 4956 KB Output is correct
30 Correct 180 ms 4956 KB Output is correct
31 Correct 204 ms 4952 KB Output is correct
32 Correct 82 ms 4956 KB Output is correct
33 Correct 208 ms 5112 KB Output is correct
34 Correct 74 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 344 KB Output is correct
6 Correct 0 ms 344 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 344 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 214 ms 4956 KB Output is correct
12 Correct 189 ms 4952 KB Output is correct
13 Correct 129 ms 4956 KB Output is correct
14 Correct 122 ms 4956 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 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 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 348 KB Output is correct
23 Correct 82 ms 2652 KB Output is correct
24 Correct 66 ms 1988 KB Output is correct
25 Correct 40 ms 1368 KB Output is correct
26 Correct 33 ms 1372 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 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 3 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 1 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 3 ms 348 KB Output is correct
42 Correct 5 ms 576 KB Output is correct
43 Correct 2 ms 348 KB Output is correct
44 Correct 32 ms 1256 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 3 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 93 ms 2752 KB Output is correct
52 Correct 151 ms 1880 KB Output is correct
53 Correct 41 ms 1880 KB Output is correct
54 Correct 28 ms 1116 KB Output is correct
55 Correct 81 ms 2396 KB Output is correct
56 Correct 17 ms 856 KB Output is correct
57 Correct 154 ms 4952 KB Output is correct
58 Correct 168 ms 4956 KB Output is correct
59 Correct 161 ms 4956 KB Output is correct
60 Correct 180 ms 4956 KB Output is correct
61 Correct 204 ms 4952 KB Output is correct
62 Correct 82 ms 4956 KB Output is correct
63 Correct 208 ms 5112 KB Output is correct
64 Correct 74 ms 4952 KB Output is correct
65 Correct 1 ms 344 KB Output is correct
66 Correct 70 ms 4952 KB Output is correct
67 Correct 154 ms 4952 KB Output is correct
68 Correct 158 ms 5120 KB Output is correct
69 Correct 23 ms 1112 KB Output is correct
70 Correct 5 ms 348 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 32 ms 1112 KB Output is correct
73 Correct 6 ms 588 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 192 ms 4956 KB Output is correct
76 Correct 194 ms 4956 KB Output is correct
77 Correct 210 ms 4956 KB Output is correct
78 Correct 215 ms 5116 KB Output is correct
79 Correct 223 ms 4956 KB Output is correct
80 Correct 228 ms 5116 KB Output is correct
81 Correct 148 ms 4952 KB Output is correct
82 Correct 145 ms 4952 KB Output is correct