QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106864#6363. Card Gameckiseki#WA 2ms3448kbC++202.0kb2023-05-19 16:20:032023-05-19 16:20:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-19 16:20:06]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3448kb
  • [2023-05-19 16:20:03]
  • 提交

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