#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve() {
int n, m;
cin >> n >> m;
vector<int> a(n), b(n), arr(n);
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n; i++) {
cin >> b[i];
arr[i] = m * max(a[i], b[i]);
}
int l = 0, r = 1e18, mid, ans = 0;
while(l <= r) {
mid = (l + r) / 2;
int over = 0, under = 0;
for(int i = 0; i < n; i++) {
if(arr[i] >= mid) over += (arr[i] - mid) / max(a[i], b[i]);
else under += (mid - arr[i]) / b[i] + ((mid - arr[i]) % b[i] ? 1 : 0);
}
if(over >= under) {
l = mid + 1;
ans = mid;
} else r = mid - 1;
}
cout << ans << "\n";
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 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 |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
67 ms |
7492 KB |
Output is correct |
12 |
Correct |
67 ms |
7260 KB |
Output is correct |
13 |
Correct |
61 ms |
7256 KB |
Output is correct |
14 |
Incorrect |
71 ms |
7260 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
34 ms |
3996 KB |
Output is correct |
10 |
Correct |
23 ms |
2652 KB |
Output is correct |
11 |
Correct |
18 ms |
2140 KB |
Output is correct |
12 |
Correct |
14 ms |
1884 KB |
Output is correct |
13 |
Correct |
0 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 |
1 ms |
572 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 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 |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
67 ms |
7492 KB |
Output is correct |
12 |
Correct |
67 ms |
7260 KB |
Output is correct |
13 |
Correct |
61 ms |
7256 KB |
Output is correct |
14 |
Incorrect |
71 ms |
7260 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
34 ms |
3996 KB |
Output is correct |
10 |
Correct |
23 ms |
2652 KB |
Output is correct |
11 |
Correct |
18 ms |
2140 KB |
Output is correct |
12 |
Correct |
14 ms |
1884 KB |
Output is correct |
13 |
Correct |
0 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 |
1 ms |
572 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 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 |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
67 ms |
7492 KB |
Output is correct |
12 |
Correct |
67 ms |
7260 KB |
Output is correct |
13 |
Correct |
61 ms |
7256 KB |
Output is correct |
14 |
Incorrect |
71 ms |
7260 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |