ソースコード
select
  rank() over(order by pt desc, ex_time asc) as RANK,
  user_id USER_ID,
  pt POINT,
  ex_time EX_TIME,
  was WRONG_ANS
FROM
(
  select
    entry.user_id,
    pt_time.pt,
    ifnull(penalty.was, 0) was,
    strftime('%s', pt_time.lastsub_at) - strftime('%s', started_at) as ex_time
  from
    entries entry
    inner join (
      select
        entry_id,
        user_id,
        max(submitted_at) lastsub_at,
        sum(point) pt
      from
        submissions
      where
        contest_id = 2
        and status = 'AC'
        and entry_id is not null
      group by user_id
      having sum(point) > 0
    ) pt_time
    on entry.user_id = pt_time.user_id
    left join (
      select
        s.user_id,
        count(1) was,
        count(1)*300 penalty
      from
        submissions s
        inner join (
          select
            user_id,
            problem_id,
            max(submitted_at) lasttime
          from submissions
          where
            status = 'AC'
            and contest_id = 2
            and entry_id is not null
        ) l
        on
          s.user_id = l.user_id
          and s.problem_id = l.problem_id
          and s.submitted_at < l.lasttime
      where
        contest_id = 2
        and status != 'AC'
        and entry_id is not null
      group by s.user_id
    ) penalty
    on entry.user_id = penalty.user_id
  where
    contest_id = 2
) master
order by RANK, WAS, USER_ID
;
提出情報
提出日時2022/10/19 21:14:28
コンテスト第3回 SQLコンテスト
問題順位計算
受験者espressivosubito
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量95 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
89 MB
データパターン2
WA
95 MB