QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#482887#6632. Minimize Mediantien_noobRE 0ms0kbC++141.5kb2024-07-18 00:02:542024-07-18 00:02:54

Judging History

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

  • [2024-07-18 00:02:54]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-18 00:02:54]
  • 提交

answer

//Make CSP great again
//Vengeance
#include <bits/stdc++.h>
#define TASK "TESTCODE"
using namespace std;
const int N = 1e6;
int n, m, k;
int a[N + 1];
int cost[N + 1];
void read()
{
    cin >> n >> m >> k;
    for (int i = 1; i <= n; ++ i)
    {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= m; ++ i)
    {
        cin >> cost[i];
    }
    for (int i = m - 1; i >= 1; -- i)
    {
        cost[i] = min(cost[i], cost[i + 1]);
    }
}
bool check(int mid)
{
    int total = 0;
    for (int i = 1; i <= (n + 1)/2; ++ i)
    {   
        if (a[i] <= mid)
        {
            continue;
        }
        total += cost[a[i]/mid];
        if (total > k)
        {
            return false;
        }
    }
    return true;
}
void solve()
{
    int low = 0, high = m;
    while(low <= high)
    {
        int mid = (low + high)/2;
        if (check(mid))
        {
            high = mid - 1;
        }
        else 
        {
            low = mid + 1;
        }
    }
    cout << low << '\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if (fopen(TASK".INP", "r"))
    {
        freopen(TASK".INP", "r", stdin);
        //freopen(TASK".OUT", "w", stdout);
    }
    int t = 1;
    bool typetest = true;
    if (typetest)
    {
        cin >> t;
    }
    for (int __ = 1; __ <= t; ++ __)
    {
        //cout << "Case " << __ << ": ";
        read();
        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: