QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#725391 | #9599. Dragon Bloodline | kjhhjki# | TL | 0ms | 3564kb | C++20 | 1.3kb | 2024-11-08 17:26:50 | 2024-11-08 17:26:52 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
void solve()
{
int n, k;
std::cin >> n >> k;
std::vector<i64> a(n + 1), b(k);
for(int i = 1; i <= n; ++i) {
std::cin >> a[i];
}
i64 carri = 0;
for(int i = 0; i < k; ++i) {
std::cin >> b[i];
carri += b[i] << i;
}
int mx = *std::ranges::max_element(a);
i64 ans = *std::ranges::partition_point(std::ranges::iota_view(1ll, carri / mx + 1),
[&](i64 x) -> bool {
auto tb = b;
std::priority_queue<i64> q;
for(int i = 1; i <= n; ++i) {
q.push(a[i] * x);
}
int cur = k - 1;
while(!q.empty()) {
i64 x = q.top(); q.pop();
while(cur >= 0 && !tb[cur]) {
--cur;
}
if(cur < 0) {
return false;
}
--tb[cur];
if(x > (1 << cur)) {
q.push(x - (1 << cur));
}
}
return true;
});
std::cout << ans - 1 << '\n';
}
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T = 1;
std::cin >> T;
while(T --) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
6 4 3 1 2 3 4 4 4 4 3 2 1 1 1 1 7 3 4 6 6 2 1 1 5 5 3 5 3 1 1 1 1 1 1 1 4 5 1 9 9 8 2 2 2 3 1 5 4 1 3 1 7 1 4 1 5 2
output:
2 4 4 5 2 3
result:
ok 6 lines
Test #2:
score: -100
Time Limit Exceeded
input:
1 1 20 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000