QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#725399#9599. Dragon Bloodlinekjhhjki#RE 0ms0kbC++201.4kb2024-11-08 17:28:352024-11-08 17:28:36

Judging History

你现在查看的是最新测评结果

  • [2024-11-08 17:28:36]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-08 17:28:35]
  • 提交

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;
                }
                i64 cnt = std::min(x / cur, tb[cur]);
                tb[cur] -= cnt;
                if(x > (cnt << cur)) {
                    q.push(x - (cnt << 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: 0
Runtime Error

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:


result: