ソースコード
WITH AC_SUB AS(
SELECT
    ENTRY_ID
    ,PROBLEM_ID
    ,USER_ID
    ,SUBMITTED_AT AS AC_SUB_TIME
    ,STARTED_AT
FROM SUBMISSIONS NATURAL JOIN ENTRIES
WHERE CONTEST_ID = '2' AND STATUS = 'AC' AND ENTRY_ID IS NOT NULL
)

SELECT
    RANK() OVER(ORDER BY SUM(POINT) DESC, STRFTIME('%s', MAX(SUBMITTED_AT)) - STRFTIME('%s', t2.STARTED_AT) + 300 *SUM(CASE WHEN t1.STATUS != 'AC' THEN 1 ELSE 0 END)) AS RANK
    ,t1.USER_ID AS USER_ID
    ,SUM(POINT) AS POINT
    ,STRFTIME('%s', MAX(SUBMITTED_AT)) - STRFTIME('%s', t2.STARTED_AT) + 300 *SUM(CASE WHEN t1.STATUS != 'AC' THEN 1 ELSE 0 END) AS EX_TIME
    ,SUM(CASE WHEN t1.STATUS != 'AC' THEN 1 ELSE 0 END) AS WRONG_ANS
FROM SUBMISSIONS t1
INNER JOIN AC_SUB t2
ON t1.ENTRY_ID = t2.ENTRY_ID AND t1.PROBLEM_ID = t2.PROBLEM_ID AND t1.USER_ID = t2.USER_ID AND t1.SUBMITTED_AT <= t2.AC_SUB_TIME
WHERE t1.CONTEST_ID = '2' AND t1.ENTRY_ID IS NOT NULL
GROUP BY t1.USER_ID
ORDER BY RANK, WRONG_ANS, USER_ID
提出情報
提出日時2023/02/21 23:33:25
コンテスト第3回 SQLコンテスト
問題順位計算
受験者mott
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量79 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
79 MB
データパターン2
AC
77 MB