# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548691 | cpp219 | Self Study (JOI22_ho_t2) | C++17 | 280 ms | 9120 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>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define debug(y) cout<<y,exit(0)
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 3e5 + 9;
const ll inf = 1e18 + 7;
int n,m,a[N],b[N];
bool chk(ll tar){
ll spare = 0;
for (ll i = 1;i <= n;i++){
ll mx = max(a[i],b[i]);
if (m*mx > tar) spare += m - ceil((ld)tar/mx);
else spare -= ceil((ld)(tar - mx*m)/b[i]);
}
return (spare >= 0);
}
int main(){
ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define task "tst"
if (fopen(task".inp","r")){
freopen(task".inp","r",stdin);
//freopen(task".out","w",stdout);
}
cin>>n>>m;
for (ll i = 1;i <= n;i++) cin>>a[i];
for (ll i = 1;i <= n;i++) cin>>b[i];
ll l,mid,h; l = 1; h = inf; //debug(chk(18));
while(l <= h){
mid = (l + h)/2;
if (chk(mid)) l = mid + 1;
else h = mid - 1;
}
cout<<h;
}
/// be confident
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... |