ソースコード
WITH u_t AS(
SELECT
    s.USER_ID,
    s.PROBLEM_ID,
    sum(case 
        when s.STATUS = 'WA' then 1
        else 0
    end) as wrongs,
    max(s.POINT) as POINT,
    min(strftime('%s', s.SUBMITTED_AT) - strftime('%s', e.STARTED_AT)) as EX_TIME
FROM SUBMISSIONS s
INNER JOIN ENTRIES e ON s.ENTRY_ID = e.ENTRY_ID
WHERE s.CONTEST_ID = 2
GROUP BY s.USER_ID,s.PROBLEM_ID),
u_s AS (
SELECT
    USER_ID,
    SUM(POINT) AS POINT,
    MAX(EX_TIME) AS EX_TIME,
    sum(case 
        when POINT > 0  then wrongs
        else 0
    end) as WRONG_ANS
FROM u_t
GROUP BY USER_ID)
SELECT
    RANK() OVER (
                ORDER BY
                    POINT DESC
                    , EX_TIME+300*WRONG_ANS
            ) AS RANK,
    USER_ID,
    POINT,
    EX_TIME+300*WRONG_ANS AS EX_TIME,
    WRONG_ANS
FROM u_s WHERE POINT >0
ORDER BY 
    RANK,
    WRONG_ANS,
    USER_ID
提出情報
提出日時2022/10/20 04:52:51
コンテスト第3回 SQLコンテスト
問題順位計算
受験者YANG
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量77 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
76 MB
データパターン2
WA
77 MB