ソースコード
SELECT
RANK() OVER(ORDER BY POINT DESC, EX_TIME) AS RANK
,USER_ID
,POINT
,EX_TIME
,WRONG_ANS
FROM
(
    SELECT
    en.USER_ID AS USER_ID
    ,sb.p_sum AS POINT
    ,strftime('%s', sb2.last_sub, 'localtime') - strftime('%s', en.STARTED_AT, 'localtime')
    + sb.wrg_cnt * 300 AS EX_TIME
    ,sb.wrg_cnt AS WRONG_ANS
    FROM
    ENTRIES AS en
    LEFT JOIN 
    (
        SELECT
        ENTRY_ID
        ,SUM(POINT) AS p_sum
        ,SUM(CASE WHEN STATUS='WA' AND 
        EXISTS (
            SELECT * FROM SUBMISSIONS AS s0
            WHERE s0.ENTRY_ID = s1.ENTRY_ID AND s0.PROBLEM_ID = s1.PROBLEM_ID AND s0.STATUS='AC'
            )
            THEN 1 ELSE 0 END) AS wrg_cnt
        FROM
        SUBMISSIONS AS s1
        GROUP BY ENTRY_ID
    ) AS sb
    ON en.ENTRY_ID = sb.ENTRY_ID
    LEFT JOIN 
    (
        SELECT
        ENTRY_ID
        ,MAX(SUBMITTED_AT) AS last_sub
        FROM
        SUBMISSIONS
        WHERE STATUS='AC'
        GROUP BY ENTRY_ID
    ) AS sb2
    ON en.ENTRY_ID = sb2.ENTRY_ID
    WHERE en.CONTEST_ID = 2
)
WHERE POINT > 0
ORDER BY RANK, WRONG_ANS, USER_ID;
提出情報
提出日時2022/10/20 13:08:25
コンテスト第3回 SQLコンテスト
問題順位計算
受験者fujiringo
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量79 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
79 MB
データパターン2
WA
79 MB