ソースコード

SELECT
    RANK() OVER(ORDER BY C.POINT DESC, EX_TIME + 300 * COALESCE(WRONG_ANS, 0) ASC , WRONG_ANS ASC) AS RANK,
    MST.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 B.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
        EXISTS (SELECT * FROM SUBMISSIONS AS T WHERE T.ENTRY_ID = T1.ENTRY_ID AND T.PROBLEM_ID = T1.PROBLEM_ID AND CONTEST_ID = 2 AND STATUS = 'AC' 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 CONTEST_ID = 2 AND STATUS = 'AC' AND ENTRY_ID IS NOT NULL))
    GROUP BY
        ENTRY_ID
) AS D ON D.ENTRY_ID = C.ENTRY_ID
WHERE
    C.POINT > 0 AND MST.ENTRY_ID IS NOT NULL
ORDER BY
    RANK,
    EX_TIME,
    WRONG_ANS
提出情報
提出日時2022/10/19 23:38:58
コンテスト第3回 SQLコンテスト
問題順位計算
受験者telestate
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量89 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
AC
89 MB
データパターン2
WA
80 MB