ソースコード
WITH t1 AS (SELECT sub.*
                 , ent.STARTED_AT
            FROM ENTRIES ent
                 JOIN SUBMISSIONS sub ON sub.ENTRY_ID = ent.ENTRY_ID
            WHERE ent.CONTEST_ID = 2
              AND sub.CONTEST_ID = 2)
   , ac AS (SELECT entry_id
                 , SUM(point) pt
                 , MAX(STRFTIME('%s', SUBMITTED_AT)) - MAX(STRFTIME('%s', STARTED_AT)) tdiff
            FROM t1
            WHERE STATUS = 'AC'
            GROUP BY ENTRY_ID)
   , wa AS (SELECT t1.entry_id
                 , COUNT(*) cnt
            FROM t1
                 JOIN (SELECT ENTRY_ID, PROBLEM_ID, SUBMITTED_AT
                       FROM t1
                       WHERE STATUS = 'AC') tac
                      ON t1.ENTRY_ID = tac.ENTRY_ID
                          AND t1.PROBLEM_ID = tac.PROBLEM_ID
                          AND t1.SUBMITTED_AT <= tac.SUBMITTED_AT
            WHERE t1.STATUS <> 'AC'
            GROUP BY t1.ENTRY_ID)
SELECT RANK() OVER (
    ORDER BY t.POINT DESC,t.EX_TIME
    ) AS RANK
     , t.*
FROM (SELECT ent.USER_ID
--            , ent.ENTRY_ID
           , ac.pt AS POINT
           , ac.tdiff + 300 * (IFNULL(wa.cnt, 0)) EX_TIME
           , IFNULL(wa.cnt, 0) WRONG_ANS
      FROM ac
           LEFT JOIN wa ON ac.ENTRY_ID = wa.ENTRY_ID
           JOIN ENTRIES ent ON ent.ENTRY_ID = ac.ENTRY_ID) t
提出情報
提出日時2024/06/14 05:12:50
コンテスト第3回 SQLコンテスト
問題順位計算
受験者pp1mqa6hkm
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
85 MB