이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
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... |