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 <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
ll n, m;
cin >> n >> m;
vector <double> a(n);
vector <double> b(n);
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++)
cin >> b[i];
for (int i = 0; i < n; i++)
a[i] = max(a[i], b[i]);
ll l = 1, r = 1000000000000000001;
while (l < r){
ll mid = (l+r)/2;
ll potrebno = 0;
for (int i = 0; i < n; i++){
ll maksa = ceil(((double) mid)/a[i]);
potrebno += min(maksa, m);
ll maksb = ceil(((double)mid- (double)min(maksa, m)*a[i])/b[i]);
potrebno += max((ll) 0, maksb);
}
if (potrebno <= n*m)
l = mid + 1;
else
r = mid;
}
cout << l - 1;
}
# | 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... |