ソースコード
WITH t AS (
    SELECT
        e.USER_ID
        , e.STARTED_AT
        , s.PROBLEM_ID
        , s.SUBMITTED_AT
        , s.STATUS
        , s.POINT
    FROM
        ENTRIES AS e
    LEFT JOIN
        SUBMISSIONS AS s
    ON
        e.ENTRY_ID = s.ENTRY_ID
        AND e.CONTEST_ID = s.CONTEST_ID
        AND e.USER_ID = s.USER_ID
    WHERE
        e.CONTEST_ID = 2
        AND s.ENTRY_ID IS NOT NULL
)
, a AS (
    SELECT
        USER_ID
        , STARTED_AT
        , PROBLEM_ID
        , SUBMITTED_AT
        , POINT
    FROM
        t
    WHERE
        STATUS = 'AC'
)
, w AS (
    SELECT
        t.USER_ID
        , COUNT() AS WRONG_ANS
    FROM
        t
    INNER JOIN
        a
    ON
        t.STATUS <> 'AC'
        AND t.USER_ID = a.USER_ID
        AND t.PROBLEM_ID = a.PROBLEM_ID
        AND t.SUBMITTED_AT < a.SUBMITTED_AT
    GROUP BY
        t.USER_ID
)
, r AS (
    SELECT
        a.USER_ID
        , SUM(a.POINT) AS POINT
        , STRFTIME('%s', MAX(a.SUBMITTED_AT)) - STRFTIME('%s', a.STARTED_AT) + IFNULL(w.WRONG_ANS, 0) * 300 AS EX_TIME
        , IFNULL(w.WRONG_ANS, 0) AS WRONG_ANS
    FROM
        a
    LEFT JOIN
        w
    ON
        a.USER_ID = w.USER_ID
    GROUP BY
        a.USER_ID
)

SELECT
    RANK () OVER (ORDER BY POINT DESC, EX_TIME ASC) AS RANK
    , *
FROM
    r
;
提出情報
提出日時2024/01/09 02:26:48
コンテスト第3回 SQLコンテスト
問題順位計算
受験者wasese
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
WA
85 MB