답안 #941833

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
941833 2024-03-09T14:36:50 Z ErJ Self Study (JOI22_ho_t2) C++17
100 / 100
333 ms 11384 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<pair<ll, ll>>
#define pp pair<ll, ll>
#define qi queue<ll>
#define qp queue<pp>
#define pqi priority_queue<ll>
#define pqp priority_queue<pp>
#define mi map<ll, ll>
#define mpi map<pp, ll>
#define mip map<ll, pp>
#define mpp map<pp, pp>
#define mb map<ll, bool>
#define si set<ll>
#define sp set<pp>
#define mod 1000000007
#define rep(a, b) for(int a = 0; a < (b); a++)
#define rep2(a, b) for(int a = 1; a < (b); a++)
#define inf 100000000000000

vi A, B;

ll n, m;

bool check(ll x) {
	ll ans = 0;
	rep(i, n) {
		ll c = max(A[i], B[i]);
		if (x < m * c) {
			ans += (x + c - 1) / c;
		}
		else {
			ans += m;
			ll y = x - c * m;
			ans += (y + B[i] - 1) / B[i];
		}
		if (ans > n * m) {
			break;
		}
	}
	if (ans <= n * m) {
		return true;
	}
	else {
		return false;
	}
}

int main()
{
	cin >> n >> m;
	A.resize(n);
	B.resize(n);
	rep(i, n) {
		cin >> A[i];
	}
	rep(i, n) {
		cin >> B[i];
	}
	ll MAX = 1000000000000000009;
	ll MIN = 0;
	while (MIN + 1 < MAX) {
		ll s = (MIN + MAX) / 2;
		bool bs = check(s);
		if (bs) {
			MIN = s;
		}
		else {
			MAX = s;
		}
	}
	cout << MIN << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 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 3 ms 348 KB Output is correct
11 Correct 199 ms 10836 KB Output is correct
12 Correct 212 ms 10836 KB Output is correct
13 Correct 150 ms 8788 KB Output is correct
14 Correct 138 ms 8816 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 62 ms 6140 KB Output is correct
17 Correct 200 ms 11384 KB Output is correct
18 Correct 217 ms 10860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 62 ms 6140 KB Output is correct
3 Correct 200 ms 11384 KB Output is correct
4 Correct 217 ms 10860 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 544 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 428 KB Output is correct
9 Correct 1 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 100 ms 5568 KB Output is correct
14 Correct 66 ms 3924 KB Output is correct
15 Correct 50 ms 2896 KB Output is correct
16 Correct 41 ms 2388 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 600 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 348 KB Output is correct
23 Correct 4 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 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 3 ms 348 KB Output is correct
11 Correct 199 ms 10836 KB Output is correct
12 Correct 212 ms 10836 KB Output is correct
13 Correct 150 ms 8788 KB Output is correct
14 Correct 138 ms 8816 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 544 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 428 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 0 ms 348 KB Output is correct
23 Correct 100 ms 5568 KB Output is correct
24 Correct 66 ms 3924 KB Output is correct
25 Correct 50 ms 2896 KB Output is correct
26 Correct 41 ms 2388 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 600 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 348 KB Output is correct
33 Correct 4 ms 600 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 62 ms 6140 KB Output is correct
36 Correct 200 ms 11384 KB Output is correct
37 Correct 217 ms 10860 KB Output is correct
38 Correct 1 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 600 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 344 KB Output is correct
45 Correct 4 ms 604 KB Output is correct
46 Correct 7 ms 708 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 35 ms 2136 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 432 KB Output is correct
51 Correct 4 ms 596 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 436 KB Output is correct
54 Correct 1 ms 440 KB Output is correct
55 Correct 108 ms 5640 KB Output is correct
56 Correct 59 ms 3132 KB Output is correct
57 Correct 48 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 544 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 428 KB Output is correct
5 Correct 1 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 100 ms 5568 KB Output is correct
10 Correct 66 ms 3924 KB Output is correct
11 Correct 50 ms 2896 KB Output is correct
12 Correct 41 ms 2388 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 600 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 348 KB Output is correct
19 Correct 4 ms 600 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 62 ms 6140 KB Output is correct
22 Correct 200 ms 11384 KB Output is correct
23 Correct 217 ms 10860 KB Output is correct
24 Correct 45 ms 1876 KB Output is correct
25 Correct 126 ms 5048 KB Output is correct
26 Correct 23 ms 1304 KB Output is correct
27 Correct 196 ms 10920 KB Output is correct
28 Correct 201 ms 10836 KB Output is correct
29 Correct 207 ms 11088 KB Output is correct
30 Correct 227 ms 10872 KB Output is correct
31 Correct 296 ms 10740 KB Output is correct
32 Correct 130 ms 6304 KB Output is correct
33 Correct 333 ms 11348 KB Output is correct
34 Correct 127 ms 6228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 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 3 ms 348 KB Output is correct
11 Correct 199 ms 10836 KB Output is correct
12 Correct 212 ms 10836 KB Output is correct
13 Correct 150 ms 8788 KB Output is correct
14 Correct 138 ms 8816 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 544 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 428 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 0 ms 348 KB Output is correct
23 Correct 100 ms 5568 KB Output is correct
24 Correct 66 ms 3924 KB Output is correct
25 Correct 50 ms 2896 KB Output is correct
26 Correct 41 ms 2388 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 600 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 348 KB Output is correct
33 Correct 4 ms 600 KB Output is correct
34 Correct 1 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 600 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 4 ms 604 KB Output is correct
42 Correct 7 ms 708 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 35 ms 2136 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 432 KB Output is correct
47 Correct 4 ms 596 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 436 KB Output is correct
50 Correct 1 ms 440 KB Output is correct
51 Correct 108 ms 5640 KB Output is correct
52 Correct 59 ms 3132 KB Output is correct
53 Correct 48 ms 3164 KB Output is correct
54 Correct 45 ms 1876 KB Output is correct
55 Correct 126 ms 5048 KB Output is correct
56 Correct 23 ms 1304 KB Output is correct
57 Correct 196 ms 10920 KB Output is correct
58 Correct 201 ms 10836 KB Output is correct
59 Correct 207 ms 11088 KB Output is correct
60 Correct 227 ms 10872 KB Output is correct
61 Correct 296 ms 10740 KB Output is correct
62 Correct 130 ms 6304 KB Output is correct
63 Correct 333 ms 11348 KB Output is correct
64 Correct 127 ms 6228 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 62 ms 6140 KB Output is correct
67 Correct 200 ms 11384 KB Output is correct
68 Correct 217 ms 10860 KB Output is correct
69 Correct 31 ms 1368 KB Output is correct
70 Correct 8 ms 604 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 44 ms 1868 KB Output is correct
73 Correct 10 ms 616 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 203 ms 10744 KB Output is correct
76 Correct 219 ms 10992 KB Output is correct
77 Correct 221 ms 10836 KB Output is correct
78 Correct 259 ms 10728 KB Output is correct
79 Correct 310 ms 10908 KB Output is correct
80 Correct 311 ms 10832 KB Output is correct
81 Correct 273 ms 8932 KB Output is correct
82 Correct 272 ms 8928 KB Output is correct