ソースコード
WITH B AS (
  SELECT
    S.*
   ,E.STARTED_AT
  FROM ENTRIES E
  JOIN SUBMISSIONS S
    ON E.ENTRY_ID = S.ENTRY_ID
  WHERE E.CONTEST_ID = 2
    AND S.ENTRY_ID IS NOT NULL
)
, T AS (
  SELECT
    ENTRY_ID
   ,SUM(POINT) POINT
   ,MAX(strftime('%s', SUBMITTED_AT) - strftime('%s', STARTED_AT)) TIME
  FROM B
  WHERE STATUS = 'AC'
  GROUP BY ENTRY_ID
), MISS AS (

  SELECT S.ENTRY_ID, COUNT(*) CNT
  FROM SUBMISSIONS S
  JOIN (
    SELECT PROBLEM_ID, ENTRY_ID, MAX(SUBMITTED_AT) SUBMITTED_AT
    FROM SUBMISSIONS
    WHERE CONTEST_ID = 2 AND STATUS = 'AC' AND ENTRY_ID IS NOT NULL
    GROUP BY PROBLEM_ID, ENTRY_ID
  ) S2
  ON   S.PROBLEM_ID = S2.PROBLEM_ID
   AND S.ENTRY_ID = S2.ENTRY_ID
  WHERE S.SUBMITTED_AT < S2.SUBMITTED_AT
  GROUP BY S.ENTRY_ID

)

SELECT
  RANK() OVER (ORDER BY POINT DESC, EX_TIME) RANK
 ,*
FROM (
SELECT
  B.USER_ID
 ,T.POINT
 ,T.TIME + (ifnull(MISS.CNT, 0) * 300) EX_TIME
 ,ifnull(MISS.CNT, 0) WRONG_ANS
FROM (SELECT ENTRY_ID, USER_ID FROM B GROUP BY ENTRY_ID, USER_ID) B
JOIN T ON B.ENTRY_ID = T.ENTRY_ID
LEFT JOIN MISS ON B.ENTRY_ID = MISS.ENTRY_ID
)
ORDER BY 1, WRONG_ANS, USER_ID
提出情報
提出日時2022/10/20 14:58:38
コンテスト第3回 SQLコンテスト
問題順位計算
受験者mine
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量80 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
AC
80 MB
データパターン2
WA
79 MB