ソースコード
WITH entry_table as (SELECT
    *
    ,min(CASE WHEN status='AC' then submitted_at else NULL end) over (PARTITION BY user_id, problem_id) as latest_ac
    FROM (entries e
    inner join submissions s
    using (entry_id, contest_id, user_id))
    where e.entry_id is not NULL
    AND e.started_at < s.submitted_at
    AND e.contest_id = 2
),
preprops as (SELECT
    user_id
    ,SUM(CASE WHEN status='AC' THEN strftime('%s', latest_ac) - strftime('%s',started_at) ELSE 0 END) as TIME_TO_ANSWER
    ,SUM(CASE WHEN status='WA' and  latest_ac > submitted_at THEN 1 ELSE 0 END) as wrong_cnt
    ,SUM(point) as POINT
    from entry_table
    group by user_id
),
props as (SELECT
    user_id as USER_ID
    ,TIME_TO_ANSWER + wrong_cnt*300 as EX_TIME
    ,point as POINT
    ,wrong_cnt as WRONG_ANS
    from preprops
    where POINT > 0
)
SELECT
    RANK() OVER (ORDER BY POINT DESC, EX_TIME ASC, WRONG_ANS ASC) as RANK
    , USER_ID
    , POINT
    ,WRONG_ANS
    ,EX_TIME
FROM props









提出情報
提出日時2022/11/02 11:04:44
コンテスト第3回 SQLコンテスト
問題順位計算
受験者drillmachine
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
83 MB
データパターン2
WA
86 MB