ソースコード
with org as (
select
    a.*
from submissions as a
inner join (
    select
        b.*
    from submissions as b
    where b.status = 'AC'
        and b.contest_id = 2
        and b.entry_id is not null
) as c
    on a.user_id = c.user_id
        and a.problem_id = c.problem_id
        and a.submitted_at < c.submitted_at
), org2 as (
    select
        user_id
        , count() as num_wrong_ans
    from org
    group by 1
)
select
    rank() over (order by sum_point desc, strftime('%s', d.last_submitted) - strftime('%s', f.started_at) + 300 * ifnull(e.num_wrong_ans, 0)) as RANK
    , d.user_id as USER_ID
    , d.sum_point as POINT
    , strftime('%s', d.last_submitted) - strftime('%s', f.started_at) + 300 * ifnull(e.num_wrong_ans, 0) as EX_TIME
    , ifnull(e.num_wrong_ans, 0) as WRONG_ANS
from (
    select
        user_id
        , sum(point) as sum_point
        , max(submitted_at) as last_submitted
    from submissions
    where contest_id = 2
        and entry_id is not null
    group by user_id
) as d
left outer join org2 as e
    on d.user_id = e.user_id
inner join entries as f
    on d.user_id = f.user_id
order by RANK, e.num_wrong_ans, d.user_id
;
提出情報
提出日時2023/04/15 18:06:14
コンテスト第3回 SQLコンテスト
問題順位計算
受験者s4wara_o
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量78 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
77 MB
データパターン2
WA
78 MB