QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#504864 | #6632. Minimize Median | hcywoi | Compile Error | / | / | C++20 | 1.3kb | 2024-08-04 16:49:32 | 2024-08-04 16:49:33 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
void solve() {
int N, M, K;
std::cin >> N >> M >> K;
std::vector<int> A(N);
for (int i = 0; i < N; i++) {
std::cin >> A[i];
}
std::vector<int> cost(M + 2);
for (int i = 1; i <= M; i++) {
std::cin >> cost[i];
}
cost[M + 1] = K + 1;
cost[1] = 0;
for (int i = 1; i <= M; i++) {
for (int j = 1; ; j++) {
if (i * j <= M) {
cost[i * j] = std::min(cost[i * j], cost[i] + cost[j]);
} else {
cost[M + 1] = std::min(cost[M + 1], cost[i] + cost[j]);
break;
}
}
for (int i = M; i >= 1; i--) {
cost[i] = std::min(cost[i], cost[i + 1]);
}
std::sort(A.begin(), A.end());
auto ans = *std::ranges::partition_point(std::ranges::iota_view(0, M),
[&](int x) {
i64 tot = 0;
for (int i = 0; i <= N / 2; i++) {
tot += cost[A[i] / (x + 1) + 1];
}
return tot > K;
});
std::cout << ans << "\n";
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}
詳細信息
answer.code: In function ‘void solve()’: answer.code:44:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 44 | int main() { | ^~ answer.code:44:9: note: remove parentheses to default-initialize a variable 44 | int main() { | ^~ | -- answer.code:44:9: note: or replace parentheses with braces to value-initialize a variable answer.code:44:12: error: a function-definition is not allowed here before ‘{’ token 44 | int main() { | ^ answer.code:56:2: error: expected ‘}’ at end of input 56 | } | ^ answer.code:5:14: note: to match this ‘{’ 5 | void solve() { | ^