ソースコード
WITH LAC AS (
    SELECT
        ENTRY_ID,
        SUM(POINT) AS POINT,
        MAX(SUBMITTED_AT) SUBMITTED_AT
    FROM
        SUBMISSIONS
    WHERE
        CONTEST_ID=2 AND STATUS = 'AC'
    GROUP BY
        ENTRY_ID
)
, WA AS (
    SELECT
        S.ENTRY_ID,
        COUNT() AS COUNT
    FROM
        SUBMISSIONS S
        LEFT OUTER JOIN
        LAC
        ON
            S.ENTRY_ID = LAC.ENTRY_ID
    WHERE
        S.CONTEST_ID=2
        AND S.SUBMITTED_AT < LAC.SUBMITTED_AT
        AND STATUS = 'WA'
    GROUP BY
        S.ENTRY_ID
),
D AS (
SELECT
    E.USER_ID AS USER_ID,
    LAC.POINT AS POINT,
    ( strftime('%s',LAC.SUBMITTED_AT) - strftime('%s',E.STARTED_AT) ) + CASE WHEN WA.COUNT IS NULL THEN 0 ELSE WA.COUNT * 300 END AS EX_TIME,
    CASE WHEN WA.COUNT IS NULL THEN 0 ELSE WA.COUNT END AS WRONG_ANS
FROM
    ENTRIES E
    LEFT OUTER JOIN
    LAC
    ON
        E.ENTRY_ID = LAC.ENTRY_ID
    LEFT OUTER JOIN
    WA
    ON
        E.ENTRY_ID = WA.ENTRY_ID
WHERE
    E.CONTEST_ID=2
GROUP BY
    E.USER_ID,
    E.ENTRY_ID
HAVING
    SUM(LAC.POINT)>0 AND SUM(LAC.POINT) IS NOT NULL
)
SELECT
    RANK() OVER ( ORDER BY POINT DESC, EX_TIME ASC ) AS RANK,
    USER_ID,
    POINT,
    EX_TIME,
    WRONG_ANS
FROM
    D
ORDER BY
    1 ASC,
    5 ASC,
    2 ASC
提出情報
提出日時2022/10/19 13:38:04
コンテスト第3回 SQLコンテスト
問題順位計算
受験者sasausa
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量94 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
81 MB
データパターン2
AC
94 MB