ソースコード
with v1 as
(
    select
        ENT.USER_ID as USER_ID
    ,   SUB.POINT as SCORE
    ,   SUB.PROBLEM_ID as PROB
    ,   STATUS as STATUS
    ,   strftime('%s', ENT.STARTED_AT) as START
    ,   strftime('%s', SUB.SUBMITTED_AT) as SUBMIT
    from
        SUBMISSIONS SUB
    join
        ENTRIES ENT
    on
        ENT.ENTRY_ID = SUB.ENTRY_ID
    and ENT.CONTEST_ID = SUB.CONTEST_ID
    and ENT.USER_ID = SUB.USER_ID
    where
        SUB.CONTEST_ID = '2'
    and ENT.ENTRY_ID is not NULL
)
, RES as
(
    select
        v1.USER_ID as USER_ID
    ,   sum(v1.SCORE) as POINT
    ,   max(AC.SUBMIT) - AC.START + sum(v1.SUBMIT<AC.SUBMIT) * 300 as EX_TIME
    ,   sum(v1.SUBMIT<AC.SUBMIT) as WRONG_ANS
    from
        v1
    join
        ( select * from v1 where v1.STATUS = 'AC' ) as AC
    on
        v1.USER_ID = AC.USER_ID
    and v1.PROB = AC.PROB
    group by
        v1.USER_ID
    having
        POINT > 0
)
select
    RANK() OVER(ORDER BY RES.POINT DESC, RES.EX_TIME) as RANK
,   RES.USER_ID
,   RES.POINT
,   RES.EX_TIME
,   RES.WRONG_ANS
from
    RES
order by
    RANK
,   WRONG_ANS
,   USER_ID
提出情報
提出日時2022/10/20 21:41:35
コンテスト第3回 SQLコンテスト
問題順位計算
受験者marocas
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量79 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
78 MB
データパターン2
AC
79 MB