ソースコード
SELECT
    RANK() OVER(
        ORDER BY
            SUM(POINT) DESC,
            (
                STRFTIME('%s', MAX(CASE WHEN STATUS = 'AC' THEN SUBMITTED_AT END))
                - STRFTIME('%s', MAX(STARTED_AT))
                + 300 * SUM(CASE WHEN STATUS <> 'AC' AND SUBMITTED_AT < FIRST_AC_AT THEN 1 ELSE 0 END)
            ) ASC
    ) AS RANK,
    USER_ID,
    SUM(POINT) AS POINT,
    (
        STRFTIME('%s', MAX(CASE WHEN STATUS = 'AC' THEN SUBMITTED_AT END))
        - STRFTIME('%s', MAX(STARTED_AT))
        + 300 * SUM(CASE WHEN STATUS <> 'AC' AND SUBMITTED_AT < FIRST_AC_AT THEN 1 ELSE 0 END)
    ) AS EX_TIME,
    SUM(CASE WHEN STATUS <> 'AC' AND SUBMITTED_AT < FIRST_AC_AT THEN 1 ELSE 0 END) AS WRONG_ANS
FROM (
    SELECT
        CONTEST_ID,
        PROBLEM_ID,
        USER_ID,
        ENTRY_ID,
        SUBMITTED_AT,
        STATUS,
        POINT,
        (
            SELECT
                MIN(SUBMITTED_AT)
            FROM
                SUBMISSIONS AS S2
            WHERE
                S1.CONTEST_ID = S2.CONTEST_ID
                AND S1.PROBLEM_ID = S2.PROBLEM_ID
                AND S1.USER_ID = S2.USER_ID
                AND S2.STATUS = 'AC'
                AND ENTRY_ID IS NOT NULL
        ) AS FIRST_AC_AT
    FROM
        SUBMISSIONS AS S1
    WHERE
        CONTEST_ID = 2
        AND ENTRY_ID IS NOT NULL
)
INNER JOIN
    ENTRIES USING (ENTRY_ID, USER_ID, CONTEST_ID)
GROUP BY
    USER_ID
HAVING
    SUM(POINT) > 0
ORDER BY
    RANK ASC,
    WRONG_ANS ASC,
    USER_ID ASC
;
提出情報
提出日時2023/08/23 22:20:33
コンテスト第3回 SQLコンテスト
問題順位計算
受験者naku6aru
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量78 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
77 MB
データパターン2
AC
78 MB