답안 #585784

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
585784 2022-06-29T10:45:52 Z Drew_ Self Study (JOI22_ho_t2) C++17
100 / 100
292 ms 11500 KB
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x) cerr << "[" << #x << "]: " << x << "\n";

using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using pl = pair<ll, ll>;

constexpr ld PI = 4*atan((ld)1);
constexpr int MAX = 3e5 + 69;

ll n, m;
ll a[MAX], b[MAX];

#define ll __int128_t
inline bool check(ll val)
{
	ll sum = 0;
	for (int i = 0; i < n; ++i)
	{
		ll cur = val;
		if (a[i] > b[i])
		{
			ll attend = min((__int128_t)m, (cur + a[i] - 1) / a[i]);
			sum += attend;
			cur -= attend * a[i];
		}
		if (cur > 0) sum += (cur + b[i] - 1) / b[i];
	}

	return sum <= n*m;
}
#undef ll

int main()
{
	fastio;

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

	ll l = 1, r = 1e18;
	while (l < r)
	{
		ll mid = (l + r + 1) >> 1;
		if (check(mid)) l = mid;
		else r = mid-1;
	}

	cout << l << '\n';

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 6 ms 468 KB Output is correct
11 Correct 282 ms 10752 KB Output is correct
12 Correct 261 ms 10700 KB Output is correct
13 Correct 163 ms 8816 KB Output is correct
14 Correct 292 ms 8716 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 194 ms 6124 KB Output is correct
17 Correct 177 ms 11500 KB Output is correct
18 Correct 160 ms 10744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 194 ms 6124 KB Output is correct
3 Correct 177 ms 11500 KB Output is correct
4 Correct 160 ms 10744 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Correct 0 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 84 ms 5564 KB Output is correct
14 Correct 55 ms 3916 KB Output is correct
15 Correct 42 ms 2892 KB Output is correct
16 Correct 34 ms 2388 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 4 ms 340 KB Output is correct
23 Correct 3 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 6 ms 468 KB Output is correct
11 Correct 282 ms 10752 KB Output is correct
12 Correct 261 ms 10700 KB Output is correct
13 Correct 163 ms 8816 KB Output is correct
14 Correct 292 ms 8716 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 328 KB Output is correct
17 Correct 0 ms 328 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 328 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 84 ms 5564 KB Output is correct
24 Correct 55 ms 3916 KB Output is correct
25 Correct 42 ms 2892 KB Output is correct
26 Correct 34 ms 2388 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 4 ms 340 KB Output is correct
33 Correct 3 ms 468 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 194 ms 6124 KB Output is correct
36 Correct 177 ms 11500 KB Output is correct
37 Correct 160 ms 10744 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 324 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 5 ms 468 KB Output is correct
46 Correct 9 ms 596 KB Output is correct
47 Correct 2 ms 340 KB Output is correct
48 Correct 46 ms 2004 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 5 ms 500 KB Output is correct
52 Correct 1 ms 324 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 138 ms 5544 KB Output is correct
56 Correct 57 ms 3152 KB Output is correct
57 Correct 112 ms 3156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 84 ms 5564 KB Output is correct
10 Correct 55 ms 3916 KB Output is correct
11 Correct 42 ms 2892 KB Output is correct
12 Correct 34 ms 2388 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 4 ms 340 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 194 ms 6124 KB Output is correct
22 Correct 177 ms 11500 KB Output is correct
23 Correct 160 ms 10744 KB Output is correct
24 Correct 32 ms 1896 KB Output is correct
25 Correct 89 ms 5056 KB Output is correct
26 Correct 19 ms 1412 KB Output is correct
27 Correct 158 ms 10688 KB Output is correct
28 Correct 166 ms 10792 KB Output is correct
29 Correct 161 ms 10732 KB Output is correct
30 Correct 172 ms 10700 KB Output is correct
31 Correct 233 ms 10800 KB Output is correct
32 Correct 212 ms 6092 KB Output is correct
33 Correct 238 ms 11492 KB Output is correct
34 Correct 214 ms 6180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 6 ms 468 KB Output is correct
11 Correct 282 ms 10752 KB Output is correct
12 Correct 261 ms 10700 KB Output is correct
13 Correct 163 ms 8816 KB Output is correct
14 Correct 292 ms 8716 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 328 KB Output is correct
17 Correct 0 ms 328 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 328 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 84 ms 5564 KB Output is correct
24 Correct 55 ms 3916 KB Output is correct
25 Correct 42 ms 2892 KB Output is correct
26 Correct 34 ms 2388 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 4 ms 340 KB Output is correct
33 Correct 3 ms 468 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 324 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 5 ms 468 KB Output is correct
42 Correct 9 ms 596 KB Output is correct
43 Correct 2 ms 340 KB Output is correct
44 Correct 46 ms 2004 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 5 ms 500 KB Output is correct
48 Correct 1 ms 324 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 138 ms 5544 KB Output is correct
52 Correct 57 ms 3152 KB Output is correct
53 Correct 112 ms 3156 KB Output is correct
54 Correct 32 ms 1896 KB Output is correct
55 Correct 89 ms 5056 KB Output is correct
56 Correct 19 ms 1412 KB Output is correct
57 Correct 158 ms 10688 KB Output is correct
58 Correct 166 ms 10792 KB Output is correct
59 Correct 161 ms 10732 KB Output is correct
60 Correct 172 ms 10700 KB Output is correct
61 Correct 233 ms 10800 KB Output is correct
62 Correct 212 ms 6092 KB Output is correct
63 Correct 238 ms 11492 KB Output is correct
64 Correct 214 ms 6180 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 194 ms 6124 KB Output is correct
67 Correct 177 ms 11500 KB Output is correct
68 Correct 160 ms 10744 KB Output is correct
69 Correct 35 ms 1428 KB Output is correct
70 Correct 8 ms 596 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 40 ms 1828 KB Output is correct
73 Correct 10 ms 584 KB Output is correct
74 Correct 2 ms 340 KB Output is correct
75 Correct 271 ms 10792 KB Output is correct
76 Correct 271 ms 10900 KB Output is correct
77 Correct 285 ms 10700 KB Output is correct
78 Correct 265 ms 10700 KB Output is correct
79 Correct 273 ms 10904 KB Output is correct
80 Correct 269 ms 10700 KB Output is correct
81 Correct 218 ms 8788 KB Output is correct
82 Correct 236 ms 8780 KB Output is correct