// 01001100 01001111 01010100 01000001 \\
// \\
// ╦ ╔═╗╔╦╗╔═╗ \\
// ║ ║ ║ ║ ╠═╣ \\
// ╩═╝╚═╝ ╩ ╩ ╩ \\
// \\
// 01001100 01001111 01010100 01000001 \\
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define ld long double
#define terminator main
#define pll pair<ll,ll>
#define add insert
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const int N = 3e5 + 6;
ll n, m;
ll a[N];
ll b[N];
bool check(ll x){
ll p, q, r;
p = q = 0;
for(int i = 0; i < n && p < n * m; i++){
r = (x + a[i] - 1) / a[i];
if(r > m){
r = (x - a[i] * m + b[i] - 1) / b[i];
p += r;
}
else if(r < m) q += m - r;
}
if(p > q) return 0;
return 1;
}
void solve(){
cin >> n >> m;
for(int i = 0; i < n; i++)
cin >> a[i];
for(int i = 0; i < n; i++){
cin >> b[i];
a[i] = max(a[i], b[i]);
}
ll ans = 0;
for(ll i = 576460752303423488; i > 0; i /= 2)
if(check(ans + i)) ans += i;
cout << ans;
}
int terminator(){
L0TA;
int T = 1;
//cin >> T;
while(T--)
solve();
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |