# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
538089 |
2022-03-16T05:17:13 Z |
ddy888 |
Self Study (JOI22_ho_t2) |
C++17 |
|
243 ms |
5028 KB |
#undef _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define pb push_back
#define fi first
#define si second
#define ar array
typedef pair<int,int> pi;
typedef tuple<int,int,int> ti;
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {cerr<<" "<<to_string(H);debug_out(T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
int N, M;
int A[300010], B[300010];
int good(int x) {
int cnt = 0;
for (int i = 1; i <= N; ++i) {
int co, st;
if (A[i] >= B[i]) {
if (M * A[i] < x) {
co = M;
st = (x - (M * A[i]) + B[i] - 1) / B[i];
} else {
co = (x + A[i] - 1) / A[i];
st = 0;
}
} else {
st = (x + B[i] - 1) / B[i];
co = 0;
}
cnt += co + st;
if (cnt > N * M) return 0;
}
return 1;
}
signed main() {
fast;
cin >> N >> M;
for (int i = 1; i <= N; ++i) cin >> A[i];
for (int i = 1; i <= N; ++i) cin >> B[i];
int lo = 0, hi = 6e18;
while (lo + 1 < hi) {
int mid = (lo + hi) / 2;
if (good(mid)) lo = mid;
else hi = mid;
}
cout << lo;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
122 ms |
4940 KB |
Output is correct |
12 |
Correct |
107 ms |
5004 KB |
Output is correct |
13 |
Correct |
93 ms |
4920 KB |
Output is correct |
14 |
Correct |
81 ms |
5000 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
33 ms |
4956 KB |
Output is correct |
17 |
Correct |
112 ms |
4892 KB |
Output is correct |
18 |
Correct |
98 ms |
5000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
33 ms |
4956 KB |
Output is correct |
3 |
Correct |
112 ms |
4892 KB |
Output is correct |
4 |
Correct |
98 ms |
5000 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
340 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 |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
53 ms |
2752 KB |
Output is correct |
14 |
Correct |
34 ms |
1904 KB |
Output is correct |
15 |
Correct |
23 ms |
1440 KB |
Output is correct |
16 |
Correct |
20 ms |
1212 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
0 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 |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
122 ms |
4940 KB |
Output is correct |
12 |
Correct |
107 ms |
5004 KB |
Output is correct |
13 |
Correct |
93 ms |
4920 KB |
Output is correct |
14 |
Correct |
81 ms |
5000 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
340 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 |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
53 ms |
2752 KB |
Output is correct |
24 |
Correct |
34 ms |
1904 KB |
Output is correct |
25 |
Correct |
23 ms |
1440 KB |
Output is correct |
26 |
Correct |
20 ms |
1212 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
3 ms |
340 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
33 ms |
4956 KB |
Output is correct |
36 |
Correct |
112 ms |
4892 KB |
Output is correct |
37 |
Correct |
98 ms |
5000 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
0 ms |
212 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
0 ms |
212 KB |
Output is correct |
43 |
Correct |
0 ms |
212 KB |
Output is correct |
44 |
Correct |
1 ms |
212 KB |
Output is correct |
45 |
Correct |
2 ms |
340 KB |
Output is correct |
46 |
Correct |
4 ms |
460 KB |
Output is correct |
47 |
Correct |
1 ms |
340 KB |
Output is correct |
48 |
Correct |
19 ms |
1136 KB |
Output is correct |
49 |
Correct |
0 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
340 KB |
Output is correct |
51 |
Correct |
2 ms |
340 KB |
Output is correct |
52 |
Correct |
1 ms |
212 KB |
Output is correct |
53 |
Correct |
0 ms |
212 KB |
Output is correct |
54 |
Correct |
0 ms |
212 KB |
Output is correct |
55 |
Correct |
54 ms |
2640 KB |
Output is correct |
56 |
Correct |
33 ms |
1888 KB |
Output is correct |
57 |
Correct |
33 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 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 |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
53 ms |
2752 KB |
Output is correct |
10 |
Correct |
34 ms |
1904 KB |
Output is correct |
11 |
Correct |
23 ms |
1440 KB |
Output is correct |
12 |
Correct |
20 ms |
1212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
33 ms |
4956 KB |
Output is correct |
22 |
Correct |
112 ms |
4892 KB |
Output is correct |
23 |
Correct |
98 ms |
5000 KB |
Output is correct |
24 |
Correct |
30 ms |
1048 KB |
Output is correct |
25 |
Correct |
75 ms |
2412 KB |
Output is correct |
26 |
Correct |
17 ms |
836 KB |
Output is correct |
27 |
Correct |
98 ms |
4980 KB |
Output is correct |
28 |
Correct |
102 ms |
5004 KB |
Output is correct |
29 |
Correct |
126 ms |
4940 KB |
Output is correct |
30 |
Correct |
134 ms |
4940 KB |
Output is correct |
31 |
Correct |
210 ms |
4888 KB |
Output is correct |
32 |
Correct |
132 ms |
5008 KB |
Output is correct |
33 |
Correct |
220 ms |
4988 KB |
Output is correct |
34 |
Correct |
100 ms |
4996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
122 ms |
4940 KB |
Output is correct |
12 |
Correct |
107 ms |
5004 KB |
Output is correct |
13 |
Correct |
93 ms |
4920 KB |
Output is correct |
14 |
Correct |
81 ms |
5000 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
340 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 |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
53 ms |
2752 KB |
Output is correct |
24 |
Correct |
34 ms |
1904 KB |
Output is correct |
25 |
Correct |
23 ms |
1440 KB |
Output is correct |
26 |
Correct |
20 ms |
1212 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
3 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Correct |
0 ms |
212 KB |
Output is correct |
39 |
Correct |
0 ms |
212 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
2 ms |
340 KB |
Output is correct |
42 |
Correct |
4 ms |
460 KB |
Output is correct |
43 |
Correct |
1 ms |
340 KB |
Output is correct |
44 |
Correct |
19 ms |
1136 KB |
Output is correct |
45 |
Correct |
0 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
340 KB |
Output is correct |
47 |
Correct |
2 ms |
340 KB |
Output is correct |
48 |
Correct |
1 ms |
212 KB |
Output is correct |
49 |
Correct |
0 ms |
212 KB |
Output is correct |
50 |
Correct |
0 ms |
212 KB |
Output is correct |
51 |
Correct |
54 ms |
2640 KB |
Output is correct |
52 |
Correct |
33 ms |
1888 KB |
Output is correct |
53 |
Correct |
33 ms |
1876 KB |
Output is correct |
54 |
Correct |
30 ms |
1048 KB |
Output is correct |
55 |
Correct |
75 ms |
2412 KB |
Output is correct |
56 |
Correct |
17 ms |
836 KB |
Output is correct |
57 |
Correct |
98 ms |
4980 KB |
Output is correct |
58 |
Correct |
102 ms |
5004 KB |
Output is correct |
59 |
Correct |
126 ms |
4940 KB |
Output is correct |
60 |
Correct |
134 ms |
4940 KB |
Output is correct |
61 |
Correct |
210 ms |
4888 KB |
Output is correct |
62 |
Correct |
132 ms |
5008 KB |
Output is correct |
63 |
Correct |
220 ms |
4988 KB |
Output is correct |
64 |
Correct |
100 ms |
4996 KB |
Output is correct |
65 |
Correct |
0 ms |
212 KB |
Output is correct |
66 |
Correct |
33 ms |
4956 KB |
Output is correct |
67 |
Correct |
112 ms |
4892 KB |
Output is correct |
68 |
Correct |
98 ms |
5000 KB |
Output is correct |
69 |
Correct |
22 ms |
840 KB |
Output is correct |
70 |
Correct |
7 ms |
340 KB |
Output is correct |
71 |
Correct |
0 ms |
212 KB |
Output is correct |
72 |
Correct |
34 ms |
988 KB |
Output is correct |
73 |
Correct |
7 ms |
468 KB |
Output is correct |
74 |
Correct |
2 ms |
340 KB |
Output is correct |
75 |
Correct |
115 ms |
5000 KB |
Output is correct |
76 |
Correct |
120 ms |
5000 KB |
Output is correct |
77 |
Correct |
138 ms |
5000 KB |
Output is correct |
78 |
Correct |
155 ms |
4940 KB |
Output is correct |
79 |
Correct |
219 ms |
4940 KB |
Output is correct |
80 |
Correct |
243 ms |
5004 KB |
Output is correct |
81 |
Correct |
230 ms |
5000 KB |
Output is correct |
82 |
Correct |
188 ms |
5028 KB |
Output is correct |