# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
907604 | AlphaMale06 | Self Study (JOI22_ho_t2) | C++14 | 204 ms | 10888 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define int long long
void solve(){
int n, m;
cin >> n >> m;
int a[n], b[n];
for(int i=0; i< n; i++)cin >> a[i];
for(int i=0; i< n; i++)cin >> b[i];
int l=0; int r=1e18+1;
int ans=0;
while(l<=r){
int s=l+r>>1;
int save=n*m;
for(int i=0; i< n; i++){
int temp=s;
int mx=max(a[i], b[i]);
if(mx*m<=s){
temp-=mx*m;
save-=m;
save-=(temp+b[i]-1)/b[i];
}
else{
save-=(s+mx-1)/mx;
}
if(save<0){
break;
}
}
if(save>=0){
ans=s;
l=s+1;
}
else r=s-1;
}
cout << ans << '\n';
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
}
Compilation message (stderr)
# | 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... |