ソースコード

SELECT
    RANK () OVER (ORDER BY POINT DESC, EX_TIME) RANK,
    USER_ID,
    POINT,
    EX_TIME,
    WRONG_ANS
FROM (
SELECT
    USER_ID,
    POINT,
    EX_TIME+WRONG_ANS*300 EX_TIME,
    WRONG_ANS
FROM (
    SELECT
        USER_ID,
        SUM(POINT) POINT,
        MAX(EX_TIME) EX_TIME,
        SUM(coalesce(
            CASE WHEN AC_TIME IS NOT NULL
            THEN (
                SELECT
                    COUNT(*)
                FROM
                    SUBMISSIONS
                WHERE
                    USER_ID = TMP.USER_ID
                    AND
                    PROBLEM_ID = TMP.PROBLEM_ID
                    AND
                    SUBMITTED_AT < TMP.AC_TIME
                GROUP BY
                    PROBLEM_ID
            )
            ELSE 0
            END
        , 0)) WRONG_ANS
    FROM (
        SELECT
            S.USER_ID,
            S.PROBLEM_ID,
            SUM(S.POINT) POINT,
            CASE WHEN S.STATUS = 'AC'
                THEN (unixepoch(S.SUBMITTED_AT)-unixepoch(E.STARTED_AT))
                ELSE 0
            END EX_TIME,
            MAX(
                CASE WHEN S.STATUS = 'AC' THEN S.SUBMITTED_AT ELSE NULL END
            ) AC_TIME
        FROM
            SUBMISSIONS S
        JOIN
            ENTRIES E
            ON S.USER_ID = E.USER_ID
        WHERE
            S.CONTEST_ID = 2
            AND
            S.ENTRY_ID IS NOT NULL
        GROUP BY
            S.USER_ID,
            S.PROBLEM_ID
    ) TMP
    GROUP BY
        USER_ID
    HAVING
        SUM(POINT) > 0
) TMP2
) TMP3
提出情報
提出日時2022/10/22 11:24:58
コンテスト第3回 SQLコンテスト
問題順位計算
受験者kkrz57C
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量77 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
AC
76 MB
データパターン2
WA
77 MB