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 <bits/stdc++.h>
using namespace std;
vector<long long> haha(0);
vector<long long> bruh(0);
long long n,m;
bool check(long long a) {
long long br = 0;
for(long long i = 0; i < n; i++) {
if(haha[i] <= bruh[i]) {
br+=(a-1)/bruh[i]+1;
}
else {
if(a > haha[i]*m) {
br+=m;
br+=(a-1-haha[i]*m)/bruh[i]+1;
}
else {
br+=(a-1)/haha[i]+1;
}
}
if(br > n*m) {
return false;
}
}
if(br > n*m) {
return false;
}
else {
return true;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m;
long long a;
for(long long i = 0; i < n; i++) {
cin >> a;
haha.push_back(a);
}
for(long long i = 0; i < n; i++) {
cin >> a;
bruh.push_back(a);
}
long long l = 0,r = 1e18;
while(l < r) {
long long mid = (l+r+1)/2;
if(check(mid)) {
l = mid;
}
else {
r = mid-1;
}
}
cout << l;
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... |