# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
938095 |
2024-03-04T19:38:44 Z |
esomer |
Self Study (JOI22_ho_t2) |
C++17 |
|
223 ms |
8784 KB |
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
long long N, M; cin >> N >> M;
vector<int> A(N);
for(auto &i : A) cin >> i;
vector<int> B(N);
for(auto &i : B) cin >> i;
long long lo = 0;
long long hi = 1e18;
long long bst = 0;
while(lo <= hi){
long long mid = (lo + hi) / 2;
long long need = 0;
for(int i = 0; i < N && need <= N * M; i++){
long long needClass = (mid + max(A[i], B[i]) - 1) / max(A[i], B[i]);
if(needClass <= M){
need += needClass;
continue;
}
need += M;
long long left = mid - max(A[i], B[i]) * M;
need += (left + B[i] - 1) / B[i];
}
if(need <= N*M){
bst = mid;
lo = mid + 1;
}else hi = mid - 1;
}
cout << bst << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
460 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
580 KB |
Output is correct |
11 |
Correct |
83 ms |
8020 KB |
Output is correct |
12 |
Correct |
83 ms |
8164 KB |
Output is correct |
13 |
Correct |
78 ms |
6228 KB |
Output is correct |
14 |
Correct |
57 ms |
6376 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
28 ms |
3924 KB |
Output is correct |
17 |
Correct |
91 ms |
8740 KB |
Output is correct |
18 |
Correct |
82 ms |
8420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
28 ms |
3924 KB |
Output is correct |
3 |
Correct |
91 ms |
8740 KB |
Output is correct |
4 |
Correct |
82 ms |
8420 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 |
0 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 |
44 ms |
4548 KB |
Output is correct |
14 |
Correct |
29 ms |
3164 KB |
Output is correct |
15 |
Correct |
21 ms |
2396 KB |
Output is correct |
16 |
Correct |
19 ms |
2096 KB |
Output is correct |
17 |
Correct |
1 ms |
548 KB |
Output is correct |
18 |
Correct |
1 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
3 ms |
576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
460 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
580 KB |
Output is correct |
11 |
Correct |
83 ms |
8020 KB |
Output is correct |
12 |
Correct |
83 ms |
8164 KB |
Output is correct |
13 |
Correct |
78 ms |
6228 KB |
Output is correct |
14 |
Correct |
57 ms |
6376 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 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 |
44 ms |
4548 KB |
Output is correct |
24 |
Correct |
29 ms |
3164 KB |
Output is correct |
25 |
Correct |
21 ms |
2396 KB |
Output is correct |
26 |
Correct |
19 ms |
2096 KB |
Output is correct |
27 |
Correct |
1 ms |
548 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
3 ms |
576 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
28 ms |
3924 KB |
Output is correct |
36 |
Correct |
91 ms |
8740 KB |
Output is correct |
37 |
Correct |
82 ms |
8420 KB |
Output is correct |
38 |
Correct |
0 ms |
348 KB |
Output is correct |
39 |
Correct |
0 ms |
452 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Correct |
0 ms |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
348 KB |
Output is correct |
43 |
Correct |
1 ms |
348 KB |
Output is correct |
44 |
Correct |
1 ms |
348 KB |
Output is correct |
45 |
Correct |
2 ms |
348 KB |
Output is correct |
46 |
Correct |
3 ms |
696 KB |
Output is correct |
47 |
Correct |
1 ms |
348 KB |
Output is correct |
48 |
Correct |
17 ms |
1748 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
0 ms |
344 KB |
Output is correct |
51 |
Correct |
2 ms |
348 KB |
Output is correct |
52 |
Correct |
0 ms |
452 KB |
Output is correct |
53 |
Correct |
0 ms |
348 KB |
Output is correct |
54 |
Correct |
0 ms |
348 KB |
Output is correct |
55 |
Correct |
46 ms |
4364 KB |
Output is correct |
56 |
Correct |
31 ms |
2392 KB |
Output is correct |
57 |
Correct |
20 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 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 |
44 ms |
4548 KB |
Output is correct |
10 |
Correct |
29 ms |
3164 KB |
Output is correct |
11 |
Correct |
21 ms |
2396 KB |
Output is correct |
12 |
Correct |
19 ms |
2096 KB |
Output is correct |
13 |
Correct |
1 ms |
548 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
3 ms |
576 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
28 ms |
3924 KB |
Output is correct |
22 |
Correct |
91 ms |
8740 KB |
Output is correct |
23 |
Correct |
82 ms |
8420 KB |
Output is correct |
24 |
Correct |
29 ms |
1624 KB |
Output is correct |
25 |
Correct |
70 ms |
4092 KB |
Output is correct |
26 |
Correct |
12 ms |
1112 KB |
Output is correct |
27 |
Correct |
80 ms |
8276 KB |
Output is correct |
28 |
Correct |
92 ms |
8424 KB |
Output is correct |
29 |
Correct |
93 ms |
8272 KB |
Output is correct |
30 |
Correct |
118 ms |
8276 KB |
Output is correct |
31 |
Correct |
189 ms |
8272 KB |
Output is correct |
32 |
Correct |
135 ms |
3960 KB |
Output is correct |
33 |
Correct |
216 ms |
8784 KB |
Output is correct |
34 |
Correct |
154 ms |
3960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
460 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
580 KB |
Output is correct |
11 |
Correct |
83 ms |
8020 KB |
Output is correct |
12 |
Correct |
83 ms |
8164 KB |
Output is correct |
13 |
Correct |
78 ms |
6228 KB |
Output is correct |
14 |
Correct |
57 ms |
6376 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 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 |
44 ms |
4548 KB |
Output is correct |
24 |
Correct |
29 ms |
3164 KB |
Output is correct |
25 |
Correct |
21 ms |
2396 KB |
Output is correct |
26 |
Correct |
19 ms |
2096 KB |
Output is correct |
27 |
Correct |
1 ms |
548 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
3 ms |
576 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
452 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
0 ms |
348 KB |
Output is correct |
39 |
Correct |
1 ms |
348 KB |
Output is correct |
40 |
Correct |
1 ms |
348 KB |
Output is correct |
41 |
Correct |
2 ms |
348 KB |
Output is correct |
42 |
Correct |
3 ms |
696 KB |
Output is correct |
43 |
Correct |
1 ms |
348 KB |
Output is correct |
44 |
Correct |
17 ms |
1748 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
0 ms |
344 KB |
Output is correct |
47 |
Correct |
2 ms |
348 KB |
Output is correct |
48 |
Correct |
0 ms |
452 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
0 ms |
348 KB |
Output is correct |
51 |
Correct |
46 ms |
4364 KB |
Output is correct |
52 |
Correct |
31 ms |
2392 KB |
Output is correct |
53 |
Correct |
20 ms |
2396 KB |
Output is correct |
54 |
Correct |
29 ms |
1624 KB |
Output is correct |
55 |
Correct |
70 ms |
4092 KB |
Output is correct |
56 |
Correct |
12 ms |
1112 KB |
Output is correct |
57 |
Correct |
80 ms |
8276 KB |
Output is correct |
58 |
Correct |
92 ms |
8424 KB |
Output is correct |
59 |
Correct |
93 ms |
8272 KB |
Output is correct |
60 |
Correct |
118 ms |
8276 KB |
Output is correct |
61 |
Correct |
189 ms |
8272 KB |
Output is correct |
62 |
Correct |
135 ms |
3960 KB |
Output is correct |
63 |
Correct |
216 ms |
8784 KB |
Output is correct |
64 |
Correct |
154 ms |
3960 KB |
Output is correct |
65 |
Correct |
0 ms |
348 KB |
Output is correct |
66 |
Correct |
28 ms |
3924 KB |
Output is correct |
67 |
Correct |
91 ms |
8740 KB |
Output is correct |
68 |
Correct |
82 ms |
8420 KB |
Output is correct |
69 |
Correct |
21 ms |
1112 KB |
Output is correct |
70 |
Correct |
6 ms |
600 KB |
Output is correct |
71 |
Correct |
0 ms |
348 KB |
Output is correct |
72 |
Correct |
31 ms |
1632 KB |
Output is correct |
73 |
Correct |
6 ms |
600 KB |
Output is correct |
74 |
Correct |
1 ms |
460 KB |
Output is correct |
75 |
Correct |
95 ms |
7924 KB |
Output is correct |
76 |
Correct |
110 ms |
8176 KB |
Output is correct |
77 |
Correct |
122 ms |
8172 KB |
Output is correct |
78 |
Correct |
157 ms |
8272 KB |
Output is correct |
79 |
Correct |
211 ms |
8124 KB |
Output is correct |
80 |
Correct |
223 ms |
8112 KB |
Output is correct |
81 |
Correct |
195 ms |
6484 KB |
Output is correct |
82 |
Correct |
196 ms |
6376 KB |
Output is correct |