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<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool can_achieve_min_level(long long N,long long M,const vector<long long>& A,const vector<long long>& B,long long X) {
long long total_lessons=N*M;
long long lessons_needed=0;
for(long long i=0; i<N; ++i) {
if(A[i]>=X) {
continue;
}
long long lessons_to_attend=(X+A[i]-1)/A[i];
lessons_needed+=lessons_to_attend;
}
return lessons_needed<=total_lessons;
}
long long maximize_min_level(long long N, long long M,const vector<long long>& A,const vector<long long>& B) {
long long low=0,high=*max_element(A.begin(),A.end())*M;
while(low<high) {
long long mid=(low+high+1)/2;
if(can_achieve_min_level(N,M,A,B,mid)) {
low=mid;
} else {
high=mid-1;
}
}
return low;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long N,M;
cin>>N>>M;
vector<long long> A(N),B(N);
for(long long i=0; i<N; ++i) {
cin>>A[i];
}
for(long long i=0; i<N; ++i) {
cin>>B[i];
}
long long result=maximize_min_level(N,M,A,B);
cout<<result<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |