ソースコード
select
    RANK() OVER ( 
        ORDER BY
            POINT DESC
            , strftime('%s', SUBMITTED_AT) - strftime('%s', STARTED_AT) + IFNULL(WRONG_ANS, 0) * 300 ASC
    ) AS RANK
    , USER_ID
    , POINT
    , strftime('%s', SUBMITTED_AT) - strftime('%s', STARTED_AT) + IFNULL(WRONG_ANS, 0) * 300 AS EX_TIME
    , IFNULL(WRONG_ANS, 0)  as WRONG_ANS
from
    ( 
        select
            S.USER_ID
            , SUM(S.POINT) AS POINT
            , MIN(E.STARTED_AT) AS STARTED_AT
            , MAX( 
                CASE 
                    WHEN S.STATUS = 'AC' 
                        THEN S.SUBMITTED_AT 
                    ELSE NULL 
                    END
            ) AS SUBMITTED_AT
            , PENA.WRONG_ANS
        from
            SUBMISSIONS as S 
            inner join ENTRIES as E 
                on E.ENTRY_ID = S.ENTRY_ID 
            left join ( 
                SELECT
                    S.ENTRY_ID
                    , COUNT(SUBMIT_ID) AS WRONG_ANS 
                FROM
                    SUBMISSIONS AS S 
                    INNER JOIN ( 
                        SELECT
                            ENTRY_ID
                            , PROBLEM_ID
                            , MAX(SUBMITTED_AT) AS LAST_SUBMITTED_AT 
                        FROM
                            SUBMISSIONS 
                        WHERE
                            STATUS = 'AC' 
                            AND ENTRY_ID IS NOT NULL 
                            AND CONTEST_ID = 2 
                        GROUP BY
                            ENTRY_ID
                            , PROBLEM_ID
                    ) AS SUB1 
                        ON S.ENTRY_ID = SUB1.ENTRY_ID 
                        AND S.PROBLEM_ID = SUB1.PROBLEM_ID 
                        AND S.SUBMITTED_AT < SUB1.LAST_SUBMITTED_AT 
                GROUP BY
                    S.ENTRY_ID
            ) AS PENA 
                ON PENA.ENTRY_ID = S.ENTRY_ID
        where
            S.ENTRY_ID IS NOT NULL 
            AND S.CONTEST_ID = 2 
        group by
            S.USER_ID
            , PENA.WRONG_ANS
            
    ) 
order by
    RANK
    , WRONG_ANS
    , USER_ID
提出情報
提出日時2024/11/01 15:41:58
コンテスト第3回 SQLコンテスト
問題順位計算
受験者kawano
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
85 MB
データパターン2
WA
85 MB