이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <climits>
using namespace std;
typedef long long ll;
bool works(ll mid, vector<ll> classes, vector<ll> selfstudy, ll n, ll m){
ll time = n*m;
for(ll i = 0; i<ll(classes.size()); i++){
if(classes[i] > selfstudy[i]){
if(m * classes[i] >= mid){
time -= (mid + classes[i] - 1) / classes[i];
}
else{
time -= m;
time -= (mid - m * classes[i] + selfstudy[i] - 1) / selfstudy[i];
}
}
else {
time -= (mid + selfstudy[i] - 1) / selfstudy[i];
}
}
return time>=0;
}
int main() {
ll n, m;
cin >> n >> m;
vector<ll> classes(n), selfstudy(n);
for (int i = 0; i < n; i++) {
cin >> classes[i];
}
for (int i = 0; i < n; i++) {
cin >> selfstudy[i];
}
ll lo = 0, hi = ll(1e16), best = 0;
while (lo <= hi) {
ll mid = lo + (hi - lo) / 2;
if (works(mid, classes, selfstudy, n, m)) {
best = mid;
lo = mid + 1;
} else {
hi = mid - 1;
}
}
cout << best << endl;
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... |