이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
ll a[300100];
ll b[300100];
ll n, m;
bool check(ll x){
__int128 h = 0;
//cout<<x<<' ';
for(int i=1; i<=n; i++){
if(a[i] > b[i]){
if(m * a[i] < x){
h += m;
h += (x - m * a[i] - 1) / b[i] + 1;
}
else{
h += (x - 1) / a[i] + 1;
}
}
else{
h += (x - 1) / b[i] + 1;
}
}
//cout<<h<<'\n';
return h <= m*n;
}
void solve(){
cin>>n>>m;
for(int i=1; i<=n; i++){
cin>>a[i];
}
for(int i=1; i<=n; i++){
cin>>b[i];
}
ll l=0, r=2e18;
while(l < r){
ll mid=(l+r)/2;
if(check(mid)) l = mid + 1;
else r = mid;
}
cout<<r - 1;
}
signed main(){
solve();
}
# | 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... |