QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#106864 | #6363. Card Game | ckiseki# | WA | 2ms | 3448kb | C++20 | 2.0kb | 2023-05-19 16:20:03 | 2023-05-19 16:20:06 |
Judging History
answer
#include <bits/stdc++.h>
#ifdef CKISEKI
#define safe cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange(#a, a)
using std::cerr;
template <typename ...T>
void debug_(const char *s, T ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int cnt = sizeof...(T);
(..., (cerr << a << (--cnt ? ", " : ")\e[0m\n")));
}
template <typename I>
void orange_(const char *s, I L, I R) {
cerr << "\e[1;32m[ " << s << " ] = [ ";
for (int f = 0; L != R; ++L)
cerr << (f++ ? ", " : "") << *L;
cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) ((void)0)
#define orange(...) ((void)0)
#endif
#define all(v) begin(v),end(v)
using namespace std;
int main() {
cin.tie(nullptr) -> sync_with_stdio(false);
int n, m, k, d;
cin >> n >> m >> k >> d;
vector<int> c(m), a(k);
for (int &ci : c) cin >> ci;
for (int &ai : a) cin >> ai;
a.push_back(1), a.push_back(n);
sort(c.begin(), c.end());
sort(a.begin(), a.end());
bool gt = false;
for (size_t i = 1; i < a.size(); ++i) {
gt |= a[i] - a[i - 1] > d;
}
int64_t ans = 0;
if (gt) {
cout << "Here\n";
for (int i = 1; i < m; ++i)
ans += c[i];
for (size_t i = 1; i < a.size(); ++i)
if (a[i] - a[i - 1] > d)
ans += c[0];
} else {
auto valid = [&](size_t p) {
vector<int> lp(c.size() - p);
for (size_t i = 1; i + 1 < a.size(); ++i) {
if (a[i] - lp[i % p] > d)
return false;
lp[i % p] = a[i];
}
return n - *min_element(lp.begin(), lp.end()) <= d;
};
size_t L = 0, R = c.size();
while (R - L > 1) {
size_t M = (L + R) >> 1;
if (valid(M)) L = M;
else R = M;
}
for (size_t i = 0; i < L; ++i)
ans += c[i];
}
cout << ans << '\n';
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3448kb
input:
36 11 1 4 2 4 4 2 4 1 4 4 4
output:
Here 29
result:
wrong output format YES or NO expected, but HERE found