이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll; typedef pair<int, int> pii;
#define pb emplace_back
#define AI(x) begin(x),end(x)
#define ff first
#define ss second
#ifdef OWO
#define debug(args...) LKJ("\033[0;32m[ " + string(#args) + " ]\033[0m", args)
template<class I> void LKJ(I&&x) { cerr << x << endl; }
template<class I, class...T> void LKJ(I&&x, T&&...t) { cerr << x << ", "; LKJ(t...); }
template<class I> void OI(I a, I b) { while (a < b) cerr << *a << " \n"[next(a) == b]; }
#else
#define debug(...) 0
#define OI(...) 0
#endif
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll N, M; cin >> N >> M;
vector<ll> A(N), B(N);
for (ll &i: A) cin >> i;
for (ll &i: B) cin >> i;
ll ans = 0;
for (ll l = (1ll << 60); l > 0; l >>= 1) {
ll threshold = ans + l;
debug(threshold);
ll empty = N * M;
for (int i = 0; i < N; ++i) {
ll tmp = threshold;
if (A[i] >= B[i]) {
ll chooseA = (tmp + A[i] - 1) / A[i];
chooseA = min(chooseA, M);
tmp -= A[i] * chooseA;
empty -= chooseA;
//debug(i, chooseA);
}
if (tmp > 0) {
ll chooseB = (tmp + B[i] - 1) / B[i];
//debug(i, chooseB);
empty -= chooseB;
}
}
if (empty >= 0) ans = threshold;
}
cout << ans << '\n';
ll dd = LLONG_MAX;
for (int i = 0; i < N; ++i)
dd = min(dd, max(A[i], B[i]));
assert(dd == ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:14:20: warning: statement has no effect [-Wunused-value]
14 | #define debug(...) 0
| ^
Main.cpp:29:3: note: in expansion of macro 'debug'
29 | debug(threshold);
| ^~~~~
# | 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... |