ソースコード
with submissions_extra as (
    select
        E.started_at,
        S.user_id,
        S.problem_id,
        S.submitted_at,
        S.status,
        S.point,
        min(case when S.status = 'AC' then S.submitted_at else null end) over (partition by S.user_id, S.problem_id) as first_ac_time
    from
        entries E
        inner join submissions S
        on E.entry_id = S.entry_id
),
user_results as (
    select
        user_id,
        sum(point) as total_point,
        max(case when status = 'AC' then strftime('%s', submitted_at) else 0 end) - max(strftime('%s', started_at)) +
            300 * sum(case when status = 'WA' and submitted_at < first_ac_time then 1 else 0 end) as ex_time,
        sum(case when status = 'WA' and submitted_at < first_ac_time then 1 else 0 end) as wrong_count
    from
        submissions_extra
    group by
        user_id
    having
        total_point > 0
)
select
    rank() over (order by total_point desc, ex_time) as RANK,
    user_id as USER_ID,
    total_point as POINT,
    ex_time as EX_TIME,
    wrong_count as WRONG_ANS
from
    user_results
order by
    rank,
    wrong_ans,
    user_id
;
提出情報
提出日時2022/12/15 18:41:31
コンテスト第3回 SQLコンテスト
問題順位計算
受験者tekihei2317
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量80 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
AC
80 MB
データパターン2
WA
79 MB