#include <bits/stdc++.h>
using namespace std;
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;
}
cout << bst << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 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 |
1 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 |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
460 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
225 ms |
7168 KB |
Output is correct |
12 |
Correct |
203 ms |
7400 KB |
Output is correct |
13 |
Correct |
212 ms |
5868 KB |
Output is correct |
14 |
Incorrect |
430 ms |
5860 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
352 KB |
Output is correct |
9 |
Correct |
103 ms |
4188 KB |
Output is correct |
10 |
Correct |
70 ms |
2896 KB |
Output is correct |
11 |
Correct |
51 ms |
2392 KB |
Output is correct |
12 |
Correct |
43 ms |
2076 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 |
9 ms |
348 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 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 |
1 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 |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
460 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
225 ms |
7168 KB |
Output is correct |
12 |
Correct |
203 ms |
7400 KB |
Output is correct |
13 |
Correct |
212 ms |
5868 KB |
Output is correct |
14 |
Incorrect |
430 ms |
5860 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
352 KB |
Output is correct |
9 |
Correct |
103 ms |
4188 KB |
Output is correct |
10 |
Correct |
70 ms |
2896 KB |
Output is correct |
11 |
Correct |
51 ms |
2392 KB |
Output is correct |
12 |
Correct |
43 ms |
2076 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 |
9 ms |
348 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 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 |
1 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 |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
460 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
225 ms |
7168 KB |
Output is correct |
12 |
Correct |
203 ms |
7400 KB |
Output is correct |
13 |
Correct |
212 ms |
5868 KB |
Output is correct |
14 |
Incorrect |
430 ms |
5860 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |