#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int n, k; cin >> n >> k; vector<int> a(n), b(n);
for(int i=0;i<n;i++) cin >> a[i];
for(int i=0;i<n;i++) cin >> b[i];
int l=0, r=4e18;
while(l<r) {
int m = l+(r-l+1)/2, c = 0;
for(int i=0;i<n;i++) {
int x = (m+max(a[i],b[i])-1)/max(a[i],b[i]);
if(m <= k*max(a[i],b[i])) c += (k-(m+max(a[i],b[i])-1)/max(a[i],b[i]));
else c -= (m-k*max(a[i],b[i])+b[i]-1)/b[i];
}
if(c >= 0) l = m;
else r = m-1;
}
cout << l;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:12:8: warning: unused variable 'x' [-Wunused-variable]
12 | int x = (m+max(a[i],b[i])-1)/max(a[i],b[i]);
| ^
# |
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 |
3 ms |
584 KB |
Output is correct |
11 |
Correct |
200 ms |
10832 KB |
Output is correct |
12 |
Correct |
182 ms |
10836 KB |
Output is correct |
13 |
Correct |
153 ms |
8696 KB |
Output is correct |
14 |
Incorrect |
166 ms |
8696 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
436 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
98 ms |
5672 KB |
Output is correct |
10 |
Correct |
62 ms |
3920 KB |
Output is correct |
11 |
Correct |
46 ms |
2908 KB |
Output is correct |
12 |
Correct |
37 ms |
2488 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 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 |
348 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 |
3 ms |
584 KB |
Output is correct |
11 |
Correct |
200 ms |
10832 KB |
Output is correct |
12 |
Correct |
182 ms |
10836 KB |
Output is correct |
13 |
Correct |
153 ms |
8696 KB |
Output is correct |
14 |
Incorrect |
166 ms |
8696 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
436 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
98 ms |
5672 KB |
Output is correct |
10 |
Correct |
62 ms |
3920 KB |
Output is correct |
11 |
Correct |
46 ms |
2908 KB |
Output is correct |
12 |
Correct |
37 ms |
2488 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 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 |
348 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 |
3 ms |
584 KB |
Output is correct |
11 |
Correct |
200 ms |
10832 KB |
Output is correct |
12 |
Correct |
182 ms |
10836 KB |
Output is correct |
13 |
Correct |
153 ms |
8696 KB |
Output is correct |
14 |
Incorrect |
166 ms |
8696 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |