#include <bits/stdc++.h>
using namespace std;
// #define int long long
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
long long N, M; cin >> N >> M;
vector<int> A(N);
for(auto &i : A) cin >> i;
vector<int> B(N);
for(auto &i : B) cin >> i;
long long lo = 0;
long long hi = 1e18;
long long bst = 0;
while(lo <= hi){
long long mid = (lo + hi) / 2;
long long need = 0;
for(int i = 0; i < N; i++){
long long needClass = (mid + max(A[i], B[i]) - 1) / max(A[i], B[i]);
if(needClass <= M){
need += needClass;
continue;
}
need += M;
long long left = mid - max(A[i], B[i]) * M;
need += (left + B[i] - 1) / B[i];
}
if(need <= N*M){
bst = mid;
lo = mid + 1;
}else hi = mid - 1;
}
// int bst = 2e9;
// for(int i = 0; i < N; i++) bst = min(bst, max(A[i], B[i]));
cout << bst << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
11 |
Correct |
203 ms |
2792 KB |
Output is correct |
12 |
Correct |
202 ms |
2792 KB |
Output is correct |
13 |
Correct |
207 ms |
2792 KB |
Output is correct |
14 |
Incorrect |
428 ms |
2796 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 |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
104 ms |
1568 KB |
Output is correct |
10 |
Correct |
69 ms |
1116 KB |
Output is correct |
11 |
Correct |
51 ms |
1032 KB |
Output is correct |
12 |
Correct |
47 ms |
856 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Incorrect |
8 ms |
600 KB |
Output isn't correct |
19 |
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 |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
11 |
Correct |
203 ms |
2792 KB |
Output is correct |
12 |
Correct |
202 ms |
2792 KB |
Output is correct |
13 |
Correct |
207 ms |
2792 KB |
Output is correct |
14 |
Incorrect |
428 ms |
2796 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 |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
104 ms |
1568 KB |
Output is correct |
10 |
Correct |
69 ms |
1116 KB |
Output is correct |
11 |
Correct |
51 ms |
1032 KB |
Output is correct |
12 |
Correct |
47 ms |
856 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Incorrect |
8 ms |
600 KB |
Output isn't correct |
19 |
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 |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
11 |
Correct |
203 ms |
2792 KB |
Output is correct |
12 |
Correct |
202 ms |
2792 KB |
Output is correct |
13 |
Correct |
207 ms |
2792 KB |
Output is correct |
14 |
Incorrect |
428 ms |
2796 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |