답안 #528675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528675 2022-02-21T03:44:54 Z rk42745417 Self Study (JOI22_ho_t2) C++17
100 / 100
240 ms 7240 KB
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using ld = long double;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = ll(2e18) + ll(1e15);
const double EPS = 1e-8;
static int LamyIsCute = []() {
	EmiliaMyWife
	return 48763;
}();

signed main() {
	int n, m;
	cin >> n >> m;
	vector<int> arr(n), brr(n);
	for(int &a : arr)
		cin >> a;
	for(int &a : brr)
		cin >> a;
	ll l = 0, r = LINF;
	auto check = [&](const ll k) {
		ll cur = 1LL * m * n;
		for(int i = 0; i < n; i++) {
			if(arr[i] <= brr[i]) {
				cur -= (k + brr[i] - 1) / brr[i];
			}
			else {
				ll r = k;
				ll w = min<ll>(m, (r + arr[i] - 1) / arr[i]);
				cur -= w;
				r -= w * arr[i];
				if(r > 0)
					cur -= (r + brr[i] - 1) / brr[i];
			}
			if(cur < 0)
				return false;
		}
		return true;
	};
	while(l < r) {
		ll m = l + r >> 1;
		if(check(m))
			l = m + 1;
		else
			r = m;
	}
	cout << ll(l - 1) << '\n';
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:47:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   47 |   ll m = l + r >> 1;
      |          ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 312 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 1 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 308 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 109 ms 7220 KB Output is correct
12 Correct 104 ms 6944 KB Output is correct
13 Correct 85 ms 4184 KB Output is correct
14 Correct 75 ms 6320 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 30 ms 2852 KB Output is correct
17 Correct 106 ms 3412 KB Output is correct
18 Correct 92 ms 3812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 30 ms 2852 KB Output is correct
3 Correct 106 ms 3412 KB Output is correct
4 Correct 92 ms 3812 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 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 1 ms 312 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 50 ms 3516 KB Output is correct
14 Correct 33 ms 1868 KB Output is correct
15 Correct 24 ms 1452 KB Output is correct
16 Correct 22 ms 1336 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 3 ms 372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 312 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 1 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 308 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 109 ms 7220 KB Output is correct
12 Correct 104 ms 6944 KB Output is correct
13 Correct 85 ms 4184 KB Output is correct
14 Correct 75 ms 6320 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 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 1 ms 312 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 50 ms 3516 KB Output is correct
24 Correct 33 ms 1868 KB Output is correct
25 Correct 24 ms 1452 KB Output is correct
26 Correct 22 ms 1336 KB Output is correct
27 Correct 1 ms 324 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 316 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 3 ms 372 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 30 ms 2852 KB Output is correct
36 Correct 106 ms 3412 KB Output is correct
37 Correct 92 ms 3812 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 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 3 ms 316 KB Output is correct
46 Correct 4 ms 460 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 22 ms 1244 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 0 ms 204 KB Output is correct
51 Correct 3 ms 332 KB Output is correct
52 Correct 0 ms 312 KB Output is correct
53 Correct 0 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 55 ms 3124 KB Output is correct
56 Correct 32 ms 1656 KB Output is correct
57 Correct 27 ms 1624 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 1 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 1 ms 312 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 50 ms 3516 KB Output is correct
10 Correct 33 ms 1868 KB Output is correct
11 Correct 24 ms 1452 KB Output is correct
12 Correct 22 ms 1336 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 3 ms 372 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 30 ms 2852 KB Output is correct
22 Correct 106 ms 3412 KB Output is correct
23 Correct 92 ms 3812 KB Output is correct
24 Correct 29 ms 988 KB Output is correct
25 Correct 69 ms 2216 KB Output is correct
26 Correct 13 ms 696 KB Output is correct
27 Correct 93 ms 4332 KB Output is correct
28 Correct 96 ms 6516 KB Output is correct
29 Correct 99 ms 5188 KB Output is correct
30 Correct 121 ms 4448 KB Output is correct
31 Correct 204 ms 5540 KB Output is correct
32 Correct 113 ms 3156 KB Output is correct
33 Correct 240 ms 4292 KB Output is correct
34 Correct 113 ms 2712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 312 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 1 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 308 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 109 ms 7220 KB Output is correct
12 Correct 104 ms 6944 KB Output is correct
13 Correct 85 ms 4184 KB Output is correct
14 Correct 75 ms 6320 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 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 1 ms 312 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 50 ms 3516 KB Output is correct
24 Correct 33 ms 1868 KB Output is correct
25 Correct 24 ms 1452 KB Output is correct
26 Correct 22 ms 1336 KB Output is correct
27 Correct 1 ms 324 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 316 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 3 ms 372 KB Output is correct
34 Correct 0 ms 204 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 3 ms 316 KB Output is correct
42 Correct 4 ms 460 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 22 ms 1244 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 3 ms 332 KB Output is correct
48 Correct 0 ms 312 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 55 ms 3124 KB Output is correct
52 Correct 32 ms 1656 KB Output is correct
53 Correct 27 ms 1624 KB Output is correct
54 Correct 29 ms 988 KB Output is correct
55 Correct 69 ms 2216 KB Output is correct
56 Correct 13 ms 696 KB Output is correct
57 Correct 93 ms 4332 KB Output is correct
58 Correct 96 ms 6516 KB Output is correct
59 Correct 99 ms 5188 KB Output is correct
60 Correct 121 ms 4448 KB Output is correct
61 Correct 204 ms 5540 KB Output is correct
62 Correct 113 ms 3156 KB Output is correct
63 Correct 240 ms 4292 KB Output is correct
64 Correct 113 ms 2712 KB Output is correct
65 Correct 0 ms 204 KB Output is correct
66 Correct 30 ms 2852 KB Output is correct
67 Correct 106 ms 3412 KB Output is correct
68 Correct 92 ms 3812 KB Output is correct
69 Correct 23 ms 708 KB Output is correct
70 Correct 6 ms 332 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 33 ms 876 KB Output is correct
73 Correct 7 ms 332 KB Output is correct
74 Correct 1 ms 332 KB Output is correct
75 Correct 113 ms 4708 KB Output is correct
76 Correct 124 ms 4432 KB Output is correct
77 Correct 128 ms 3776 KB Output is correct
78 Correct 167 ms 3056 KB Output is correct
79 Correct 217 ms 4292 KB Output is correct
80 Correct 221 ms 7240 KB Output is correct
81 Correct 219 ms 4168 KB Output is correct
82 Correct 235 ms 4380 KB Output is correct