QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#202175#6632. Minimize Medianarseny_y#RE 0ms0kbC++231.2kb2023-10-05 20:26:422023-10-05 20:26:42

Judging History

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

  • [2023-10-05 20:26:42]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-10-05 20:26:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define int long long

void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    for (auto &i : a) {
        cin >> i;
    }
    sort(a.begin(), a.end());
    vector<int> b(m + 1);
    for (int i = 1; i <= m; ++i) {
        cin >> b[i];
    }
    vector<int> dp(m + 1, LLONG_MAX);
    dp[1] = b[1];
    for (int i = 2; i <= m; ++i) {
        dp[i] = min(dp[i], b[i]);
        for (int j = i, cnt = 1; i * j <= m; j *= i, ++cnt) {
            dp[i * j] = min(dp[i * j], dp[i] + b[i] * cnt);
        }
    }
    int l = -1, r = a[n / 2] + 1;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        auto na = a;
        int cnt = 0;
        int sm = 0;
        for (int i = 0; cnt <= n / 2; ++i, ++cnt) {
            if (a[i] <= mid) continue;
            int x = max(2LL, a[i] / mid - 3);
            while (a[i] / x > mid) {
                ++x;
            }
            sm += dp[x];
        }
        sm <= k ? r = mid : l = mid;
    }
    cout << r << '\n';
}

int32_t main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

3
3 5 0
2 5 2
3 2 4 6 13
3 5 3
2 5 3
3 2 4 6 13
3 5 6
2 5 2
3 2 4 6 13

output:


result: