ソースコード
WITH TEMP_REC AS(
    SELECT
    S.*,E.STARTED_AT
    FROM SUBMISSIONS S
    LEFT JOIN ENTRIES E
    ON S.ENTRY_ID = E.ENTRY_ID
    WHERE 
    E.CONTEST_ID = 2 AND 
    E.ENTRY_ID IS NOT NULL AND
    STRFTIME('%s', S.SUBMITTED_AT) - STRFTIME('%s', E.STARTED_AT) <= 3600
)
,EX_REC AS(
    SELECT TEMP_REC.*
    FROM TEMP_REC
    INNER JOIN(
        SELECT ENTRY_ID, PROBLEM_ID, MAX(SUBMITTED_AT) AS AC_AT
        FROM TEMP_REC 
        WHERE STATUS = 'AC'
        GROUP BY ENTRY_ID, PROBLEM_ID
    ) A
    ON TEMP_REC.ENTRY_ID = A.ENTRY_ID AND TEMP_REC.PROBLEM_ID = A.PROBLEM_ID
    WHERE TEMP_REC.SUBMITTED_AT <= A.AC_AT
)
,SUM_REC AS(
    SELECT 
    ENTRY_ID
    ,SUM(POINT) AS POINT
    ,STRFTIME('%s', MAX(SUBMITTED_AT)) - STRFTIME('%s', MIN(STARTED_AT)) + (SUM(CASE WHEN STATUS='WA' THEN 1 ELSE 0 END) * 300) AS EX_TIME
    ,SUM(CASE WHEN STATUS='WA' THEN 1 ELSE 0 END) AS WRONG_ANS
    FROM EX_REC
    GROUP BY USER_ID
)
SELECT
RANK() OVER(ORDER BY POINT DESC, EX_TIME ASC) AS RANK
,A.*
FROM(
    SELECT 
    ENTRIES.USER_ID
    ,IFNULL(SUM_REC.POINT,0) AS POINT
    ,IFNULL(SUM_REC.EX_TIME,0) AS EX_TIME
    ,IFNULL(SUM_REC.WRONG_ANS,0) AS WRONG_ANS
    FROM ENTRIES
    LEFT JOIN SUM_REC
    ON ENTRIES.ENTRY_ID = SUM_REC.ENTRY_ID
    WHERE ENTRIES.CONTEST_ID = 2 
)A
ORDER BY RANK ASC, WRONG_ANS ASC, USER_ID ASC
提出情報
提出日時2022/12/14 18:20:05
コンテスト第3回 SQLコンテスト
問題順位計算
受験者Sora
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量80 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
80 MB
データパターン2
WA
79 MB