이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define s second
#define f first
#define pii pair<int,int>
#define ll long long
#define int ll
using namespace std;
const int N = 3e5 + 3;
int a[N],b[N],n,m,cur[N];
bool check(int x){
int need=0,have=0;
for (int i = 1; i <= n; i++){
cur[i] = max(a[i],b[i]) * m;
if (cur[i] > x){
have += (cur[i] - x) / max(a[i],b[i]);
}else if (cur[i] < x){
need += (x - cur[i] + b[i] - 1)/b[i];
}
}
return (have >= need);
}
signed main (){
ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
cin>>n>>m;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
cin >> b[i];
int l = 0,r = 3e14,res=0;
while (l <= r){
int mid = (l + r)/2;
if (check(mid)){
res=mid;
l=mid+1;
}else{
r=mid-1;
}
}
cout<<res;
}
# | 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... |