ソースコード
SELECT
    RANK() OVER(ORDER BY C.POINT DESC, EX_TIME + 300 * COALESCE(WRONG_ANS, 0) ASC) AS RANK,
    USER_ID,
    C.POINT,
    EX_TIME + COALESCE(WRONG_ANS, 0) * 300 AS EX_TIME,
    COALESCE(WRONG_ANS, 0) AS WRONG_ANS
FROM
    ENTRIES AS MST
INNER JOIN 
(
    SELECT
        E.ENTRY_ID,
        strftime('%s', ENDDT) - strftime('%s', STARTED_AT) AS EX_TIME
    FROM
        ENTRIES AS E
    INNER JOIN
    (
        SELECT
            ENTRY_ID,
            MAX(SUBMITTED_AT) AS ENDDT
        FROM
            SUBMISSIONS
        WHERE
            CONTEST_ID = 2 AND STATUS = 'AC' AND ENTRY_ID IS NOT NULL
        GROUP BY
            ENTRY_ID
    ) AS S ON E.ENTRY_ID = S.ENTRY_ID
) AS B ON MST.ENTRY_ID = B.ENTRY_ID
LEFT JOIN
(
    SELECT
        ENTRY_ID,
        SUM(POINT) AS POINT
    FROM
        SUBMISSIONS AS T1
    WHERE
        CONTEST_ID = 2 AND STATUS = 'AC' AND ENTRY_ID IS NOT NULL
    GROUP BY
        ENTRY_ID
) AS C ON MST.ENTRY_ID = C.ENTRY_ID
LEFT JOIN
(
    SELECT
        ENTRY_ID,
        COUNT(1) AS WRONG_ANS
    FROM
        SUBMISSIONS AS T1
    WHERE
        CONTEST_ID = 2 AND STATUS = 'WA' AND ENTRY_ID IS NOT NULL
        AND T1.SUBMITTED_AT < (SELECT SUBMITTED_AT FROM SUBMISSIONS AS T WHERE T.ENTRY_ID = T1.ENTRY_ID AND T.PROBLEM_ID = T1.PROBLEM_ID AND T.CONTEST_ID = 2 AND T.STATUS = 'AC' AND T.ENTRY_ID IS NOT NULL)
    GROUP BY
        ENTRY_ID
) AS D ON MST.ENTRY_ID = D.ENTRY_ID
WHERE
    C.POINT IS NOT NULL AND C.POINT > 0
ORDER BY
    RANK,
    WRONG_ANS,
    USER_ID
提出情報
提出日時2022/10/20 00:21:00
コンテスト第3回 SQLコンテスト
問題順位計算
受験者telestate
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量97 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
AC
96 MB
データパターン2
WA
97 MB