QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#482887 | #6632. Minimize Median | tien_noob | RE | 0ms | 0kb | C++14 | 1.5kb | 2024-07-18 00:02:54 | 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