답안 #526827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
526827 2022-02-16T08:24:57 Z abc864197532 Self Study (JOI22_ho_t2) C++17
100 / 100
323 ms 7224 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
	cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
	for (; l != r; ++l) cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(x...) abc("[" + string(#x) + "]", x)
#define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define test(x...) void(0)
#define owo ios::sync_with_stdio(false), cin.tie(0);
#endif
const int N = 200000;

int main () {
	owo;
	int n, m;
	cin >> n >> m;
	vector <int> a(n), b(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i], a[i] = max(a[i], b[i]);
	auto ask = [&](lli bound) {
		lli rem = 0;
		for (int i = 0; i < n; ++i) {
			lli need = (bound + a[i] - 1) / a[i];
			if (need <= m)
				rem += m - need;
			else
				rem -= (bound - 1ll * a[i] * m + b[i] - 1) / b[i];
			if (rem + 1ll * m * n < 0)
				return false;
		}
		return rem >= 0;
	};
	lli l = 0, r = 1ll << 60;
	while (r - l > 1) {
		(ask(l + r >> 1) ? l : r) = l + r >> 1;
	}
	cout << l << endl;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:51:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   51 |   (ask(l + r >> 1) ? l : r) = l + r >> 1;
      |        ~~^~~
Main.cpp:51:33: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   51 |   (ask(l + r >> 1) ? l : r) = l + r >> 1;
      |                               ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 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 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 110 ms 7208 KB Output is correct
12 Correct 114 ms 6924 KB Output is correct
13 Correct 141 ms 4196 KB Output is correct
14 Correct 91 ms 6316 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 37 ms 2976 KB Output is correct
17 Correct 152 ms 3456 KB Output is correct
18 Correct 110 ms 3856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 37 ms 2976 KB Output is correct
3 Correct 152 ms 3456 KB Output is correct
4 Correct 110 ms 3856 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 208 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 59 ms 3616 KB Output is correct
14 Correct 49 ms 1852 KB Output is correct
15 Correct 28 ms 1476 KB Output is correct
16 Correct 27 ms 1276 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 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 332 KB Output is correct
23 Correct 5 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 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 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 110 ms 7208 KB Output is correct
12 Correct 114 ms 6924 KB Output is correct
13 Correct 141 ms 4196 KB Output is correct
14 Correct 91 ms 6316 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 208 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 59 ms 3616 KB Output is correct
24 Correct 49 ms 1852 KB Output is correct
25 Correct 28 ms 1476 KB Output is correct
26 Correct 27 ms 1276 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 204 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 332 KB Output is correct
33 Correct 5 ms 332 KB Output is correct
34 Correct 0 ms 208 KB Output is correct
35 Correct 37 ms 2976 KB Output is correct
36 Correct 152 ms 3456 KB Output is correct
37 Correct 110 ms 3856 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 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 1 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 300 KB Output is correct
46 Correct 4 ms 460 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 21 ms 1244 KB Output is correct
49 Correct 1 ms 312 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 3 ms 332 KB Output is correct
52 Correct 1 ms 204 KB Output is correct
53 Correct 0 ms 208 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 65 ms 3156 KB Output is correct
56 Correct 49 ms 1764 KB Output is correct
57 Correct 30 ms 1620 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 208 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 59 ms 3616 KB Output is correct
10 Correct 49 ms 1852 KB Output is correct
11 Correct 28 ms 1476 KB Output is correct
12 Correct 27 ms 1276 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 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 1 ms 332 KB Output is correct
19 Correct 5 ms 332 KB Output is correct
20 Correct 0 ms 208 KB Output is correct
21 Correct 37 ms 2976 KB Output is correct
22 Correct 152 ms 3456 KB Output is correct
23 Correct 110 ms 3856 KB Output is correct
24 Correct 36 ms 1000 KB Output is correct
25 Correct 110 ms 2148 KB Output is correct
26 Correct 16 ms 740 KB Output is correct
27 Correct 118 ms 4288 KB Output is correct
28 Correct 117 ms 4328 KB Output is correct
29 Correct 119 ms 4352 KB Output is correct
30 Correct 148 ms 4456 KB Output is correct
31 Correct 246 ms 5648 KB Output is correct
32 Correct 157 ms 3260 KB Output is correct
33 Correct 323 ms 4284 KB Output is correct
34 Correct 172 ms 2756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 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 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 110 ms 7208 KB Output is correct
12 Correct 114 ms 6924 KB Output is correct
13 Correct 141 ms 4196 KB Output is correct
14 Correct 91 ms 6316 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 208 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 59 ms 3616 KB Output is correct
24 Correct 49 ms 1852 KB Output is correct
25 Correct 28 ms 1476 KB Output is correct
26 Correct 27 ms 1276 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 204 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 332 KB Output is correct
33 Correct 5 ms 332 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 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 1 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 300 KB Output is correct
42 Correct 4 ms 460 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 21 ms 1244 KB Output is correct
45 Correct 1 ms 312 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 3 ms 332 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 0 ms 208 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 65 ms 3156 KB Output is correct
52 Correct 49 ms 1764 KB Output is correct
53 Correct 30 ms 1620 KB Output is correct
54 Correct 36 ms 1000 KB Output is correct
55 Correct 110 ms 2148 KB Output is correct
56 Correct 16 ms 740 KB Output is correct
57 Correct 118 ms 4288 KB Output is correct
58 Correct 117 ms 4328 KB Output is correct
59 Correct 119 ms 4352 KB Output is correct
60 Correct 148 ms 4456 KB Output is correct
61 Correct 246 ms 5648 KB Output is correct
62 Correct 157 ms 3260 KB Output is correct
63 Correct 323 ms 4284 KB Output is correct
64 Correct 172 ms 2756 KB Output is correct
65 Correct 0 ms 208 KB Output is correct
66 Correct 37 ms 2976 KB Output is correct
67 Correct 152 ms 3456 KB Output is correct
68 Correct 110 ms 3856 KB Output is correct
69 Correct 25 ms 740 KB Output is correct
70 Correct 7 ms 332 KB Output is correct
71 Correct 0 ms 204 KB Output is correct
72 Correct 42 ms 852 KB Output is correct
73 Correct 8 ms 460 KB Output is correct
74 Correct 2 ms 332 KB Output is correct
75 Correct 120 ms 4672 KB Output is correct
76 Correct 138 ms 4428 KB Output is correct
77 Correct 179 ms 3892 KB Output is correct
78 Correct 180 ms 2928 KB Output is correct
79 Correct 251 ms 4364 KB Output is correct
80 Correct 247 ms 7224 KB Output is correct
81 Correct 299 ms 4172 KB Output is correct
82 Correct 240 ms 4500 KB Output is correct