제출 #932520

#제출 시각아이디문제언어결과실행 시간메모리
932520koukirocksSelf Study (JOI22_ho_t2)C++17
62 / 100
188 ms10948 KiB
#include <bits/stdc++.h> #define speed ios_base::sync_with_stdio(0); cin.tie(0) #define all(x) (x).begin(),(x).end() using namespace std; typedef long long ll; typedef long double ldb; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll MAX=3e5+10,P=998244353; const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f; ll n,m; ll a[MAX],b[MAX]; bool ok(ll low) { ll need=0; for (int i=1;i<=n;i++) { ll org=max(a[i],b[i])*m; if (org>=low) need-=(org-low)/max(a[i],b[i]); else need+=(low-org-1)/b[i]+1; if (need>oo) return false; if (need<-oo) return true; } // cout<<need<<"\n"; return (need<=0); } int main() { speed; 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=1,r=1e16; while (l<r) { ll mid=(l+r+1)/2; // cout<<l<<" "<<mid<<" "<<r<<"\n"; if (ok(mid)) l=mid; else r=mid-1; } cout<<l<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...