ソースコード
WITH SUBMISSIONS_TEMP AS
     (
         SELECT
              ENTRY_ID
             ,PROBLEM_ID
             ,SUBMITTED_AT
             ,STATUS
             ,POINT
         FROM SUBMISSIONS
         WHERE
             CONTEST_ID = 2
     )
    ,CALC_TEMP1 AS
     (
         SELECT
              MAIN.USER_ID                                                                                   AS USER_ID
             ,MIN(MAIN.STARTED_AT)                                                                           AS STARTED_AT
             ,SUM(SUB.POINT)                                                                                 AS POINT
             ,SUM(CASE WHEN SUB.STATUS != 'AC' AND SUB.SUBMITTED_AT < MAX_SUB.MAX_AC_TIME THEN 1 ELSE 0 END) AS WRONG_ANS
             ,MAX(MAX_SUB.MAX_AC_TIME)                                                                       AS MAX_AC_TIME
         FROM ENTRIES AS MAIN
              INNER JOIN SUBMISSIONS_TEMP AS SUB
                  ON MAIN.ENTRY_ID = SUB.ENTRY_ID
              INNER JOIN (SELECT ENTRY_ID, PROBLEM_ID, MAX(SUBMITTED_AT) AS MAX_AC_TIME FROM SUBMISSIONS_TEMP WHERE STATUS = 'AC' GROUP BY ENTRY_ID, PROBLEM_ID) AS MAX_SUB
                  ON SUB.ENTRY_ID   = MAX_SUB.ENTRY_ID
                 AND SUB.PROBLEM_ID = MAX_SUB.PROBLEM_ID
         WHERE MAIN.CONTEST_ID = 2
         GROUP BY MAIN.USER_ID
     )
    ,CLAC_TEMP2 AS
     (
         SELECT
              USER_ID
             ,POINT
             ,strftime('%s', MAX_AC_TIME) - strftime('%s', STARTED_AT) + (300 * WRONG_ANS) AS EX_TIME
             ,WRONG_ANS
         FROM CALC_TEMP1
     )
SELECT
     RANK() OVER(ORDER BY POINT DESC, EX_TIME) AS RANK
    ,USER_ID
    ,POINT
    ,EX_TIME
    ,WRONG_ANS
FROM CLAC_TEMP2
WHERE POINT > 0
ORDER BY RANK, WRONG_ANS, USER_ID
;
提出情報
提出日時2022/10/20 14:55:08
コンテスト第3回 SQLコンテスト
問題順位計算
受験者jalapeno
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量79 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
76 MB
データパターン2
AC
79 MB