ソースコード
with FilteredSubmissions as (
    select 
        s.*,
        e.started_at
    from Submissions s
    inner join Entries e on s.entry_id = e.entry_id
    where s.contest_id = 2
    and e.contest_id = 2
    and s.entry_id is not null
    and e.entry_id is not null
),
UserAndProblemInfo as (
    select
        user_id,
        problem_id,
        submitted_at first_ac_time,
        (
            select 
                count(*) 
            from FilteredSubmissions s1
            where s1.user_id = s2.user_id 
            and s1.problem_id = s2.problem_id
            and s1.status = 'WA'
            and s1.submitted_at < s2.submitted_at
        ) wa_count,
        point,
        started_at
    from FilteredSubmissions s2
    where status = 'AC'
),
UserInfo as (
    select
        user_id,
        sum(point) point,
        sum(wa_count) wrong_ans,
        max(unixepoch(first_ac_time)) - unixepoch(started_at) ex_time, 
        started_at
    from UserAndProblemInfo
    group by user_id
)
select
    rank() over(order by point desc, ex_time) RANK,
    user_id USER_ID,
    point POINT,
    ex_time + 300 * wrong_ans EX_TIME,
    wrong_ans WRONG_ANS
from UserInfo
order by RANK, WRONG_ANS, USER_ID
提出情報
提出日時2022/10/20 03:28:38
コンテスト第3回 SQLコンテスト
問題順位計算
受験者jau5
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量88 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
88 MB
データパターン2
WA
80 MB