ソースコード
WITH SUBS AS (
    SELECT *
    FROM SUBMISSIONS AS S NATURAL INNER JOIN ENTRIES AS E
    WHERE E.CONTEST_ID = 2
), AC AS (
    SELECT PROBLEM_ID, USER_ID, POINT, STRFTIME('%s', SUBMITTED_AT) - STRFTIME('%s', STARTED_AT) AS TIME, SUBMITTED_AT AS AC_AT
    FROM SUBS
    WHERE STATUS = "AC"
), WA AS (
    SELECT S.PROBLEM_ID AS PROBLEM_ID, S.USER_ID AS USER_ID, COUNT(*) AS WA_COUNT
    FROM SUBS AS S INNER JOIN AC
        ON S.PROBLEM_ID = AC.PROBLEM_ID AND S.USER_ID = AC.USER_ID
    WHERE STATUS = "WA" AND SUBMITTED_AT < AC_AT
    GROUP BY S.PROBLEM_ID, S.USER_ID
)
SELECT RANK() OVER (ORDER BY SUM(POINT) DESC, MAX(TIME) + SUM(CASE WHEN WA_COUNT IS NULL THEN 0 ELSE WA_COUNT END) * 5 * 60) AS RANK,
    AC.USER_ID AS USER_ID,
    SUM(POINT) AS POINT,
    MAX(TIME) + SUM(CASE WHEN WA_COUNT IS NULL THEN 0 ELSE WA_COUNT END) * 5 * 60 AS EX_TIME,
    SUM(CASE WHEN WA_COUNT IS NULL THEN 0 ELSE WA_COUNT END) AS WRONG_ANS
FROM AC LEFT OUTER JOIN WA
    ON AC.PROBLEM_ID = WA.PROBLEM_ID AND AC.USER_ID = WA.USER_ID
GROUP BY AC.USER_ID
ORDER BY POINT DESC, EX_TIME, WRONG_ANS, USER_ID
提出情報
提出日時2023/09/16 03:39:28
コンテスト第3回 SQLコンテスト
問題順位計算
受験者Haar
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量77 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
77 MB
データパターン2
AC
77 MB