ソースコード
WITH T AS (
SELECT
  strftime('%s', S.SUBMITTED_AT) - strftime('%s', E.STARTED_AT) TIME
 ,S.*
FROM ENTRIES E
JOIN SUBMISSIONS S
  ON E.ENTRY_ID = S.ENTRY_ID
WHERE E.CONTEST_ID = 2
  AND STATUS = 'AC' )

SELECT
  RANK() OVER (ORDER BY POINT DESC) RANK
 ,*
FROM (
SELECT
  USER_ID
 ,SUM(POINT) POINT
 ,SUM(EX_TIME) EX_TIME
 ,SUM(WRONG_ANS) WRONG_ANS
FROM (
SELECT
  T.PROBLEM_ID
 ,T.USER_ID
 ,T.POINT
 ,T.TIME + (ifnull(E.CNT, 0) * 300) EX_TIME
 ,ifnull(E.CNT, 0) WRONG_ANS
FROM T
LEFT JOIN (
SELECT S.PROBLEM_ID, S.USER_ID, COUNT(*) CNT
FROM SUBMISSIONS S
JOIN (
SELECT PROBLEM_ID, USER_ID, MAX(SUBMITTED_AT) SUBMITTED_AT
FROM SUBMISSIONS
WHERE CONTEST_ID = 2 AND STATUS = 'AC'
GROUP BY PROBLEM_ID, USER_ID
) S2
ON   S.PROBLEM_ID = S2.PROBLEM_ID
 AND S.USER_ID = S2.USER_ID
 AND S.SUBMITTED_AT < S2.SUBMITTED_AT
WHERE S.CONTEST_ID = 2 AND S.STATUS <> 'AC'
GROUP BY S.PROBLEM_ID, S.USER_ID
) E
ON   T.PROBLEM_ID = E.PROBLEM_ID
 AND T.USER_ID = E.USER_ID
) A
GROUP BY USER_ID
HAVING SUM(POINT) > 0
)
ORDER BY 1, WRONG_ANS, USER_ID
提出情報
提出日時2022/10/19 17:50:44
コンテスト第3回 SQLコンテスト
問題順位計算
受験者mine
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量100 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
80 MB
データパターン2
WA
100 MB