ソースコード

SELECT
    RANK () OVER (ORDER BY POINT DESC, EX_TIME) RANK,
    USER_ID,
    POINT,
    EX_TIME,
    WRONG_ANS
FROM (
    SELECT
        USER_ID,
        SUM(POINT) POINT,
        MAX(EX_TIME)+SUM((
            SELECT
                COUNT(*)*500
            FROM
                SUBMISSIONS
            WHERE
                USER_ID = TMP.USER_ID
                AND
                PROBLEM_ID = TMP.PROBLEM_ID
                AND
                unixepoch(SUBMITTED_AT) < TMP.AC_TIME
        )) EX_TIME,
        SUM((
            SELECT
                COUNT(*)
            FROM
                SUBMISSIONS
            WHERE
                USER_ID = TMP.USER_ID
                AND
                PROBLEM_ID = TMP.PROBLEM_ID
                AND
                unixepoch(SUBMITTED_AT) < TMP.AC_TIME
        )) WRONG_ANS
    FROM (
        SELECT
            S.USER_ID,
            S.PROBLEM_ID,
            SUM(S.POINT) POINT,
            MAX(
                CASE WHEN S.STATUS = 'AC'
                    THEN (unixepoch(S.SUBMITTED_AT)-unixepoch(E.STARTED_AT))
                    ELSE 0
                END
            ) EX_TIME,
            MAX(
                CASE WHEN S.STATUS = 'AC'
                    THEN unixepoch(S.SUBMITTED_AT)
                    ELSE 0
                END
            ) AC_TIME
        FROM
            SUBMISSIONS S
        JOIN
            ENTRIES E
            ON S.USER_ID = E.USER_ID
        WHERE
            S.CONTEST_ID = 2
            AND
            S.ENTRY_ID IS NOT NULL
        GROUP BY
            S.USER_ID,
            S.PROBLEM_ID
    ) TMP
    GROUP BY
        USER_ID
    HAVING
        SUM(POINT) > 0
) TMP2
ORDER BY
    RANK,
    WRONG_ANS,
    USER_ID

提出情報
提出日時2022/10/22 12:06:27
コンテスト第3回 SQLコンテスト
問題順位計算
受験者kkrz57C
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量77 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
76 MB
データパターン2
WA
77 MB