#include <bits/stdc++.h>
#define int long long
using namespace std;
using idata = vector<int>;
int N, M;
idata As, Bs;
int solve (int A, int B, int target) {
if (A < B) A = B;
if (A * M >= target)
return M - ceil(((double) target) / ((double) A));
int local = target - A * M;
return - ceil(((double)local) / ((double) B));
}
bool check (int target) {
int res = 0;
for (int i = 0; i < N; i ++)
res += solve(As[i], Bs[i], target);
return res >= 0;
}
signed main () {
cin >> N >> M;
As.resize(N); Bs.resize(N);
for (int i = 0; i < N; i ++) cin >> As[i];
for (int i = 0; i < N; i ++) cin >> Bs[i];
int a = 0;
int b = 1e18;
while (b - a > 1) {
int c = (a + b) >> 1;
if (check(c)) a = c;
else b = c;
}
cout << a << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 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 |
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 |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
296 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
274 ms |
10776 KB |
Output is correct |
12 |
Correct |
306 ms |
10732 KB |
Output is correct |
13 |
Correct |
270 ms |
8796 KB |
Output is correct |
14 |
Incorrect |
186 ms |
8684 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
0 ms |
300 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 |
212 KB |
Output is correct |
9 |
Correct |
175 ms |
5432 KB |
Output is correct |
10 |
Correct |
94 ms |
3760 KB |
Output is correct |
11 |
Correct |
80 ms |
2920 KB |
Output is correct |
12 |
Correct |
57 ms |
2396 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
300 KB |
Output is correct |
15 |
Correct |
1 ms |
300 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 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 |
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 |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
296 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
274 ms |
10776 KB |
Output is correct |
12 |
Correct |
306 ms |
10732 KB |
Output is correct |
13 |
Correct |
270 ms |
8796 KB |
Output is correct |
14 |
Incorrect |
186 ms |
8684 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
0 ms |
300 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 |
212 KB |
Output is correct |
9 |
Correct |
175 ms |
5432 KB |
Output is correct |
10 |
Correct |
94 ms |
3760 KB |
Output is correct |
11 |
Correct |
80 ms |
2920 KB |
Output is correct |
12 |
Correct |
57 ms |
2396 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
300 KB |
Output is correct |
15 |
Correct |
1 ms |
300 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 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 |
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 |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
296 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
274 ms |
10776 KB |
Output is correct |
12 |
Correct |
306 ms |
10732 KB |
Output is correct |
13 |
Correct |
270 ms |
8796 KB |
Output is correct |
14 |
Incorrect |
186 ms |
8684 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |