이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
// 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=1e15;
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 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... |