提交记录 49310


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_v41_0919 2001. 元旦激光炮·改 Compile Error 0 0 ns 0 KB C++17 1.36 KB
提交时间 评测时间
2026-09-19 15:52:55 2026-09-19 15:53:55
// 元旦激光炮·改: k-th smallest of three sorted arrays.
static inline int kth3(const int *a, int na, const int *b, int nb, const int *c, int nc, int k) {
    const int *P[3] = {a, b, c};
    int N[3] = {na, nb, nc};
    while (1) {
        int act = 0, last = 0;
        for (int i = 0; i < 3; i++) if (N[i] > 0) { act++; last = i; }
        if (act == 0) return 0;
        if (act == 1) return P[last][k - 1];
        if (k <= 1) {
            int m = 0x7fffffff;
            for (int i = 0; i < 3; i++) if (N[i] > 0 && P[i][0] < m) m = P[i][0];
            return m;
        }
        int chunk = k / act;
        if (chunk < 1) chunk = 1;
        int ci[3];
        for (int i = 0; i < 3; i++) ci[i] = (N[i] == 0) ? 0 : (N[i] < chunk ? N[i] : chunk);
        const int *p0 = P[0] + ci[0] - 1, *p1 = P[1] + ci[1] - 1, *p2 = P[2] + ci[2] - 1;
        int v0 = ci[0] ? *p0 : 0x7fffffff;
        int v1 = ci[1] ? *p1 : 0x7fffffff;
        int v2 = ci[2] ? *p2 : 0x7fffffff;
        int best;
        if (v0 <= v1 && v0 <= v2) best = 0;
        else if (v1 <= v2) best = 1;
        else best = 2;
        if (ci[best] == 0) { for (int i = 0; i < 3; i++) if (ci[i] > 0) { best = i; break; } }
        P[best] += ci[best]; N[best] -= ci[best]; k -= ci[best];
    }
}

int query_kth(const int *a, int n_a, const int *b, int n_b, const int *c, int n_c, int k) {
    return kth3(a, n_a, b, n_b, c, n_c, k);
}

CompilationN/AN/ACompile ErrorScore: N/A


Judge Duck Online | 评测鸭在线
Server Time: 2026-09-23 12:45:24 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠