#include<bits/stdc++.h>
using namespace std;
bool works(long long mid, vector<long long>& a, vector<long long>& b, long long n, long long m){
long long days = 0;
for(long long i = 0; i < n; i++){
if(mid <= a[i] * m){
days += (mid + a[i] - 1) / a[i];
}
else{
days += m + (mid - a[i] * m + b[i] - 1) / b[i];
}
if(days > n * m){
return false;
}
}
return true;
}
int main(){
long long n, m;
cin >> n >> m;
vector<long long> a(n);
for(long long i = 0; i < n; i++){
cin >> a[i];
}
vector<long long> b(n);
for(long long i = 0; i < n; i++){
cin >> b[i];
}
for(long long i = 0; i < n; i++){
a[i] = max(a[i], b[i]);
}
long long low = 0;
long long high = 1e18;
while(high - low > 1){
long long mid = (low + high)/2;
if(works(mid, a, b, n, m)){
low = mid;
}
else{
high = mid;
}
}
cout << low << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
5 ms |
452 KB |
Output is correct |
11 |
Correct |
248 ms |
10696 KB |
Output is correct |
12 |
Correct |
281 ms |
10796 KB |
Output is correct |
13 |
Correct |
194 ms |
8888 KB |
Output is correct |
14 |
Correct |
177 ms |
8768 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
97 ms |
6200 KB |
Output is correct |
17 |
Correct |
272 ms |
11340 KB |
Output is correct |
18 |
Correct |
249 ms |
10780 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
97 ms |
6200 KB |
Output is correct |
3 |
Correct |
272 ms |
11340 KB |
Output is correct |
4 |
Correct |
249 ms |
10780 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 |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
292 KB |
Output is correct |
10 |
Correct |
0 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 |
124 ms |
5436 KB |
Output is correct |
14 |
Correct |
89 ms |
3756 KB |
Output is correct |
15 |
Correct |
65 ms |
2856 KB |
Output is correct |
16 |
Correct |
51 ms |
2288 KB |
Output is correct |
17 |
Correct |
1 ms |
212 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 |
296 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
5 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
5 ms |
452 KB |
Output is correct |
11 |
Correct |
248 ms |
10696 KB |
Output is correct |
12 |
Correct |
281 ms |
10796 KB |
Output is correct |
13 |
Correct |
194 ms |
8888 KB |
Output is correct |
14 |
Correct |
177 ms |
8768 KB |
Output is correct |
15 |
Correct |
1 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 |
304 KB |
Output is correct |
19 |
Correct |
1 ms |
292 KB |
Output is correct |
20 |
Correct |
0 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 |
124 ms |
5436 KB |
Output is correct |
24 |
Correct |
89 ms |
3756 KB |
Output is correct |
25 |
Correct |
65 ms |
2856 KB |
Output is correct |
26 |
Correct |
51 ms |
2288 KB |
Output is correct |
27 |
Correct |
1 ms |
212 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 |
296 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
33 |
Correct |
5 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
97 ms |
6200 KB |
Output is correct |
36 |
Correct |
272 ms |
11340 KB |
Output is correct |
37 |
Correct |
249 ms |
10780 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 |
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 |
5 ms |
436 KB |
Output is correct |
46 |
Correct |
9 ms |
596 KB |
Output is correct |
47 |
Correct |
2 ms |
316 KB |
Output is correct |
48 |
Correct |
49 ms |
1988 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
212 KB |
Output is correct |
51 |
Correct |
5 ms |
468 KB |
Output is correct |
52 |
Correct |
1 ms |
296 KB |
Output is correct |
53 |
Correct |
1 ms |
212 KB |
Output is correct |
54 |
Correct |
1 ms |
212 KB |
Output is correct |
55 |
Correct |
127 ms |
5492 KB |
Output is correct |
56 |
Correct |
66 ms |
3120 KB |
Output is correct |
57 |
Correct |
63 ms |
3124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
292 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 |
124 ms |
5436 KB |
Output is correct |
10 |
Correct |
89 ms |
3756 KB |
Output is correct |
11 |
Correct |
65 ms |
2856 KB |
Output is correct |
12 |
Correct |
51 ms |
2288 KB |
Output is correct |
13 |
Correct |
1 ms |
212 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 |
296 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
5 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
97 ms |
6200 KB |
Output is correct |
22 |
Correct |
272 ms |
11340 KB |
Output is correct |
23 |
Correct |
249 ms |
10780 KB |
Output is correct |
24 |
Correct |
64 ms |
1996 KB |
Output is correct |
25 |
Correct |
167 ms |
4988 KB |
Output is correct |
26 |
Correct |
29 ms |
1332 KB |
Output is correct |
27 |
Correct |
266 ms |
10780 KB |
Output is correct |
28 |
Correct |
261 ms |
10732 KB |
Output is correct |
29 |
Correct |
278 ms |
10776 KB |
Output is correct |
30 |
Correct |
284 ms |
10828 KB |
Output is correct |
31 |
Correct |
365 ms |
10780 KB |
Output is correct |
32 |
Correct |
179 ms |
6092 KB |
Output is correct |
33 |
Incorrect |
406 ms |
11528 KB |
Output isn't correct |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
5 ms |
452 KB |
Output is correct |
11 |
Correct |
248 ms |
10696 KB |
Output is correct |
12 |
Correct |
281 ms |
10796 KB |
Output is correct |
13 |
Correct |
194 ms |
8888 KB |
Output is correct |
14 |
Correct |
177 ms |
8768 KB |
Output is correct |
15 |
Correct |
1 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 |
304 KB |
Output is correct |
19 |
Correct |
1 ms |
292 KB |
Output is correct |
20 |
Correct |
0 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 |
124 ms |
5436 KB |
Output is correct |
24 |
Correct |
89 ms |
3756 KB |
Output is correct |
25 |
Correct |
65 ms |
2856 KB |
Output is correct |
26 |
Correct |
51 ms |
2288 KB |
Output is correct |
27 |
Correct |
1 ms |
212 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 |
296 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
33 |
Correct |
5 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 |
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 |
5 ms |
436 KB |
Output is correct |
42 |
Correct |
9 ms |
596 KB |
Output is correct |
43 |
Correct |
2 ms |
316 KB |
Output is correct |
44 |
Correct |
49 ms |
1988 KB |
Output is correct |
45 |
Correct |
1 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
212 KB |
Output is correct |
47 |
Correct |
5 ms |
468 KB |
Output is correct |
48 |
Correct |
1 ms |
296 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
212 KB |
Output is correct |
51 |
Correct |
127 ms |
5492 KB |
Output is correct |
52 |
Correct |
66 ms |
3120 KB |
Output is correct |
53 |
Correct |
63 ms |
3124 KB |
Output is correct |
54 |
Correct |
64 ms |
1996 KB |
Output is correct |
55 |
Correct |
167 ms |
4988 KB |
Output is correct |
56 |
Correct |
29 ms |
1332 KB |
Output is correct |
57 |
Correct |
266 ms |
10780 KB |
Output is correct |
58 |
Correct |
261 ms |
10732 KB |
Output is correct |
59 |
Correct |
278 ms |
10776 KB |
Output is correct |
60 |
Correct |
284 ms |
10828 KB |
Output is correct |
61 |
Correct |
365 ms |
10780 KB |
Output is correct |
62 |
Correct |
179 ms |
6092 KB |
Output is correct |
63 |
Incorrect |
406 ms |
11528 KB |
Output isn't correct |
64 |
Halted |
0 ms |
0 KB |
- |