ソースコード
with first_ac as (
    select
        s.USER_ID,
        s.PROBLEM_ID,
        min(s.SUBMITTED_AT) as SUBMITTED_AT
    from
        SUBMISSIONS as s
    where
        s.CONTEST_ID = 2
        and s.STATUS = "AC"
        and s.ENTRY_ID is not null
    group by
        1,2
)
,sub as (
    select
        s.ENTRY_ID,
        s.USER_ID,
        sum(s.POINT) as POINT,
        max(case when s.STATUS = "AC" then s.SUBMITTED_AT end) as SUBMITTED_AT,
        count(case when s.STATUS = "WA" then 1 end) as WRONG_ANS
    from
        SUBMISSIONS as s
    inner join
        first_ac as f
        on s.USER_ID = f.USER_ID
            and s.PROBLEM_ID = f.PROBLEM_ID
            and s.SUBMITTED_AT <= f.SUBMITTED_AT
    where
        s.CONTEST_ID = 2
        and s.ENTRY_ID is not null
    group by
        1,2
    having
        POINT > 0
)
select
    rank() over (order by s.POINT desc, strftime('%s', s.SUBMITTED_AT) - strftime('%s', e.STARTED_AT) + WRONG_ANS * 300 asc) as RANK,
    e.USER_ID as USER_ID,
    s.POINT as POINT,
    strftime('%s', s.SUBMITTED_AT) - strftime('%s', e.STARTED_AT) + WRONG_ANS * 300 as EX_TIME,
    s.WRONG_ANS as WRONG_ANS
from
    ENTRIES as e
inner join
    sub as s
    on e.ENTRY_ID = s.ENTRY_ID
where
    e.CONTEST_ID = 2
order by
    1,5,2
提出情報
提出日時2022/10/19 16:52:33
コンテスト第3回 SQLコンテスト
問題順位計算
受験者suk1yak1
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量97 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
93 MB
データパターン2
AC
97 MB