이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
string to_string(string s) { return s; }
template <typename T> string to_string(T v) {
bool first = true;
string res = "[";
for (const auto &x : v) {
if (!first)
res += ", ";
first = false;
res += to_string(x);
}
res += "]";
return res;
}
void dbg_out() { cout << endl; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
cout << ' ' << to_string(H);
dbg_out(T...);
}
#ifdef DEBUG
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
signed main(void) {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N, nbSemaines;
cin >> N >> nbSemaines;
vector<int> A(N), B(N);
for (int &x : A)
cin >> x;
for (int i = 0; i < N; ++i) {
cin >> B[i];
A[i] = max(A[i], B[i]);
}
auto isGood = [&](int req) {
int delta = 0;
for (int i = 0; i < N; ++i) {
int take = (req + A[i] - 1) / A[i];
if (take <= nbSemaines)
delta += nbSemaines - take;
else
delta -= (req - nbSemaines * A[i] + B[i] - 1) / B[i];
}
return delta >= 0;
};
int lo = 0, up = 4e18;
while (lo < up) {
int mid = (lo + up + 1) / 2;
if (isGood(mid))
lo = mid;
else
up = mid - 1;
}
cout << lo << endl;
}
# | 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... |