#include "bits/stdc++.h"
using namespace std;
#define int long long
/*
▀█████████▄ ▄█ ▄█ ▄████████ ▄█ ▄████████ ▄██████▄ ████████▄ ▄████████ ▄████████
███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ▀███ ███ ███ ███ ███
███ ███ ███▌ ███ ███ ███ ███ ███ █▀ ███ ███ ███ ███ ███ █▀ ███ ███
▄███▄▄▄██▀ ███▌ ███ ███ ███ ███ ███ ███ ███ ███ ███ ▄███▄▄▄ ▄███▄▄▄▄██▀
▀▀███▀▀▀██▄ ███▌ ███ ▀███████████ ███ ███ ███ ███ ███ ███ ▀▀███▀▀▀ ▀▀███▀▀▀▀▀
███ ██▄ ███ ███ ███ ███ ███ ███ █▄ ███ ███ ███ ███ ███ █▄ ▀███████████
███ ███ ███ ███▌ ▄ ███ ███ ███▌ ▄ ███ ███ ███ ███ ███ ▄███ ███ ███ ███ ███
▄█████████▀ █▀ █████▄▄██ ███ █▀ █████▄▄██ ████████▀ ▀██████▀ ████████▀ ██████████ ███ ███
▀ ▀ ███ ███
*/
template<class T> bool setmax(T& a, const T& b){
return b < a ? a = b, 1 : 0;
}
template<class T> bool setmin(T& a, const T& b){
return a < b ? a = b, 1 : 0;
}
signed main()
{
int n , m;
cin >> n >> m;
vector<int> a(n) , b(n);
for (auto & x : a)
cin >> x;
for (auto & x : b)
cin >> x;
auto check = [&](int p){
int t = 0;
for (int i = 0; i < n; i++){
if (b[i] > a[i])
t += (p + b[i] - 1) / b[i];
else {
if (a[i] * 1ll * m >= p)
t += (p + a[i] - 1) / a[i];
else
t += m + (p - a[i] * 1ll * m + b[i] - 1) / b[i];
}
}
if (t <= n * 1ll * m)
return true;
return false;
};
int l = 0 , r = 1e18;
while(l < r){
int m = (l + r + 1) >> 1;
if (check(m))
l = m;
else r = m - 1;
}
cout << l << "\n";
return 0;
}
# |
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 |
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 |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
348 KB |
Output is correct |
11 |
Correct |
217 ms |
4956 KB |
Output is correct |
12 |
Correct |
225 ms |
5132 KB |
Output is correct |
13 |
Correct |
137 ms |
5120 KB |
Output is correct |
14 |
Incorrect |
156 ms |
5120 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
88 ms |
2652 KB |
Output is correct |
10 |
Correct |
61 ms |
1884 KB |
Output is correct |
11 |
Correct |
44 ms |
1372 KB |
Output is correct |
12 |
Correct |
36 ms |
1624 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 |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
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 |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
348 KB |
Output is correct |
11 |
Correct |
217 ms |
4956 KB |
Output is correct |
12 |
Correct |
225 ms |
5132 KB |
Output is correct |
13 |
Correct |
137 ms |
5120 KB |
Output is correct |
14 |
Incorrect |
156 ms |
5120 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
88 ms |
2652 KB |
Output is correct |
10 |
Correct |
61 ms |
1884 KB |
Output is correct |
11 |
Correct |
44 ms |
1372 KB |
Output is correct |
12 |
Correct |
36 ms |
1624 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 |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
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 |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
348 KB |
Output is correct |
11 |
Correct |
217 ms |
4956 KB |
Output is correct |
12 |
Correct |
225 ms |
5132 KB |
Output is correct |
13 |
Correct |
137 ms |
5120 KB |
Output is correct |
14 |
Incorrect |
156 ms |
5120 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |