#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <limits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
using namespace std;
using ll = long long;
void solve(){
ll n, m;
cin >> n >> m;
vector<ll> list_1(n, 0), list_2(n, 0);
for(ll i = 0; i < n; i++){
cin >> list_1[i];
}
ll curr_max = 0;
for(ll i = 0; i < n; i++){
cin >> list_2[i];
curr_max = max(curr_max, max(list_2[i], list_1[i]));
}
ll l = 0, r = m*n*curr_max;
while (l + 1 < r){
ll mid = (l + r)/2;
ll total = 0;
for(ll i = 0; i < n; i++){
if(list_1[i] > list_2[i]){
if(m * list_1[i] < mid){
total += m;
total += ceil((double)(mid - m*list_1[i])/(double)list_2[i]);
}else{
total += ceil((double)mid/(double)list_1[i]);
}
}else{
total += ceil((double)mid/(double)list_2[i]);
}
//cout << total << " " << mid << " " << i << endl;
}
if(total > m*n){
r = mid;
}else{
l = mid;
}
}
cout << l << endl;
}
bool one_test = true;
int main(){
ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
ll t = 1;
if(!one_test)cin >> t;
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
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 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
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 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |