#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
ll n, m;
cin >> n >> m;
vector <double> a(n);
vector <double> b(n);
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++)
cin >> b[i];
for (int i = 0; i < n; i++)
a[i] = max(a[i], b[i]);
ll l = 1, r = 1000000000000000001;
while (l < r){
ll mid = (l+r)/2;
ll potrebno = 0;
for (int i = 0; i < n; i++){
ll maksa = ceil(mid/a[i]);
potrebno += min(maksa, m);
ll maksb = ceil((mid-min(maksa, m)*a[i])/b[i]);
potrebno += max((ll) 0, maksb);
}
if (potrebno <= n*m)
l = mid + 1;
else
r = mid;
}
cout << l - 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
8 ms |
364 KB |
Output is correct |
11 |
Correct |
478 ms |
5068 KB |
Output is correct |
12 |
Correct |
486 ms |
4984 KB |
Output is correct |
13 |
Correct |
379 ms |
4984 KB |
Output is correct |
14 |
Incorrect |
397 ms |
4984 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
247 ms |
2636 KB |
Output is correct |
10 |
Correct |
154 ms |
1876 KB |
Output is correct |
11 |
Correct |
122 ms |
1460 KB |
Output is correct |
12 |
Correct |
100 ms |
1236 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Incorrect |
4 ms |
372 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
8 ms |
364 KB |
Output is correct |
11 |
Correct |
478 ms |
5068 KB |
Output is correct |
12 |
Correct |
486 ms |
4984 KB |
Output is correct |
13 |
Correct |
379 ms |
4984 KB |
Output is correct |
14 |
Incorrect |
397 ms |
4984 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
247 ms |
2636 KB |
Output is correct |
10 |
Correct |
154 ms |
1876 KB |
Output is correct |
11 |
Correct |
122 ms |
1460 KB |
Output is correct |
12 |
Correct |
100 ms |
1236 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Incorrect |
4 ms |
372 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
8 ms |
364 KB |
Output is correct |
11 |
Correct |
478 ms |
5068 KB |
Output is correct |
12 |
Correct |
486 ms |
4984 KB |
Output is correct |
13 |
Correct |
379 ms |
4984 KB |
Output is correct |
14 |
Incorrect |
397 ms |
4984 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |