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