이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define IO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pii pair<int,int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(),x.end()
#define de(x) cout << #x << ' ' << x << '\n';
template<class T> void prt(T l,T r){
while(l!=r) cout << *l << ' ',l++;
cout << '\n';
}
const int N=3e5+5,M=1e9+7,INF=1e18;
int a[N],b[N];
int n,m;
int test(int x){
int cnt=0;
for(int i=0;i<n;i++){
int cc=0;
if(a[i]>b[i]){
int y=(x+a[i]-1)/a[i];
if(y>m){
y=x-m*a[i];
cc+=m+(y+b[i]-1)/b[i];
}else{
cc+=y;
}
}else{
cc+=(x+b[i]-1)/b[i];
}
if(n*m-cnt<cc){
return 0;
}
}
return 1;
}
signed main(){
IO
cin >> n >> m;
for(int i=0;i<n;i++) cin >> a[i];
for(int i=0;i<n;i++){
cin >> b[i];
}
int l=0,r=INF+1;
while(r-l>1){
int mid=(l+r)/2;
if(test(mid)){
l=mid;
}else{
r=mid;
}
}
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... |