ソースコード
SELECT
      rank() OVER ( 
        ORDER BY
            NULLIF( 
                SUM( 
                    CASE 
                        WHEN a.STATUS = 'AC' 
                            THEN a.POINT 
                        ELSE NULL 
                        END
                ) 
                , 0
            ) DESC
            , NULLIF( 
                STRFTIME('%s', b2.MAX_SUBMIT_AT) - STRFTIME('%s', e.STARTED_AT) + ( 
                    300 * count( 
                        CASE 
                            WHEN a.STATUS = 'WA' 
                            AND a.SUBMITTED_AT < b2.MAX_SUBMIT_AT 
                                THEN a.STATUS 
                            ELSE NULL 
                            END
                    )
                ) 
                , 0
            ) ASC
    ) RANK
    , e.USER_ID
    , NULLIF( 
        SUM( 
            CASE 
                WHEN a.STATUS = 'AC' 
                    THEN a.POINT 
                ELSE NULL 
                END
        ) 
        , 0
    ) POINT
    , NULLIF( 
        STRFTIME('%s', b2.MAX_SUBMIT_AT) - STRFTIME('%s', e.STARTED_AT) + ( 
            300 * count( 
                CASE 
                    WHEN a.STATUS = 'WA' 
                    AND a.SUBMITTED_AT < b2.MAX_SUBMIT_AT 
                        THEN a.STATUS 
                    ELSE NULL 
                    END
            )
        ) 
        , 0
    ) EX_TIME
    , count( 
        CASE 
            WHEN a.STATUS = 'WA' 
            AND a.SUBMITTED_AT < b2.MAX_SUBMIT_AT 
                THEN a.STATUS 
            ELSE NULL 
            END
    ) WRONG_ANS 
FROM
    SUBMISSIONS a 
    INNER JOIN ( 
        SELECT
              b.SUBMIT_ID
            , b.CONTEST_ID
            , b.PROBLEM_ID
            , b.USER_ID
            , MAX( 
                CASE 
                    WHEN b.STATUS = 'AC' 
                        THEN b.SUBMITTED_AT 
                    ELSE NULL 
                    END
            ) OVER (PARTITION BY b.USER_ID) "MAX_SUBMIT_AT"
            , MAX(CASE WHEN b.STATUS = 'AC' THEN 1 ELSE 0 END) OVER (PARTITION BY b.PROBLEM_ID, b.USER_ID) ac_exsist
        FROM
            SUBMISSIONS b 
        WHERE
            b.CONTEST_ID = '2' 
            AND b.ENTRY_ID IS NOT NULL
    ) b2 
        ON a.SUBMIT_ID = b2.SUBMIT_ID 
        AND a.CONTEST_ID = b2.CONTEST_ID 
        AND a.PROBLEM_ID = b2.PROBLEM_ID 
        AND a.USER_ID = b2.USER_ID 
        AND b2.ac_exsist = 1 
    INNER JOIN ENTRIES e 
        ON a.USER_ID = e.USER_ID 
        AND a.ENTRY_ID = e.ENTRY_ID 
        AND a.CONTEST_ID = e.CONTEST_ID 
GROUP BY
    e.USER_ID 
ORDER BY
    RANK
    , WRONG_ANS DESC
    , e.USER_ID;
提出情報
提出日時2024/06/16 21:24:36
コンテスト第3回 SQLコンテスト
問題順位計算
受験者fattywhale
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量84 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
WA
84 MB