QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#221009#6632. Minimize Medianreal_sigma_teamWA 3ms11068kbC++201.9kb2023-10-21 01:56:342023-10-21 01:56:35

Judging History

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

  • [2023-10-21 01:56:35]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:11068kb
  • [2023-10-21 01:56:34]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

using ll = long long;

const int N = 1e6 + 5;
int n, m, k;
int ls[N];
vector<int> pr;
ll c[N * 2], a[N];

int divup(int x, int y) {
    return (x + y - 1) / y;
}

ll check(int x) {
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll cur = 1e18;
        for (int j = 1; j <= m; j++) {
            if(i / m <= x)
            cur = min(cur, c[i / m]);
        }
        ans += cur;
    }
    // cout << '\n';
    return ans;
}

void solve() {
    cin >> n >> m >> k;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(a, a + n);

    n -= n / 2;

    for (int i = 1; i <= m; i++) {
        cin >> c[i];
    }
    c[1] = 0;
    for (int i = m - 1; i > 0; i--) {
        c[i] = min(c[i], c[i + 1]);
    }

    for (int i = 2; i <= m; i++) {
        c[i] = min(c[i], c[i / ls[i]] + c[ls[i]]);
    }
    for (int i = m + 1; i <= m * 2; i++) {
        c[i] = 2e9;
    }


    for (int i = m - 1; i > 0; i--) {
        c[i] = min(c[i], c[i + 1]);
    }

    /*for (int i = 0; i < m; i++) {
        cout << check(i) << '\n';
    }*/

    int l = -1, r = m + 1;
    while (r - l > 1) {
        int mid = (l + r) >> 1;
        if (check(mid) <= k)
            r = mid;
        else
            l = mid;
    }

    cout << r << '\n';

    // cout << "_________\n";
}

int main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#else
    freopen("input.txt", "r", stdin);
#endif
    for (int i = 2; i < N; i++) {
        if (ls[i] == 0) {
            ls[i] = i;
            pr.push_back(i);
        }
        for (int j = 0; j < sz(pr) && 1LL * pr[j] * i < N && pr[j] <= ls[i]; j++) {
            ls[pr[j] * i] = pr[j];
        }
    }
    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 11068kb

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:

0
0
0

result:

wrong answer 1st numbers differ - expected: '2', found: '0'