ソースコード
with
  a as (
    select
      entry_id,
      sum(point) as P
    from
      SUBMISSIONS
    where
      contest_id = 2
      and entry_id is not null
    group by
      entry_id
  ),
  b as (
    select
      entry_id,
      PROBLEM_ID,
      SUBMITTED_AT
    from
      SUBMISSIONS
    where
      contest_id = 2
      and entry_id is not null
      and STATUS = 'AC'
  ),
  c as (
    select
      sub.entry_id,
      count(*) as cnt
    from
      SUBMISSIONS sub
      join b on sub.entry_id = b.entry_id
      and sub.problem_id = b.problem_id
      and sub.submitted_at < b.submitted_at
    where
      sub.contest_id = 2
      and sub.entry_id is not null
      and sub.status <> 'AC'
    group by
      sub.entry_id
  )
select
  RANK() OVER (
    ORDER BY
      POINT DESC,
      EX_TIME
  ) as 'RANK',
  USER_ID,
  POINT,
  EX_TIME,
  WRONG_ANS
from
  (
    select
      sub.USER_ID,
      max(a.P) as POINT,
      max(
        strftime('%s', bm.max_t) - strftime('%s', ent.STARTED_AT) + ifnull(c.cnt, 0) * 300
      ) as EX_TIME,
      max(ifnull(c.cnt, 0)) as WRONG_ANS
    from
      submissions sub
      join a on sub.entry_id = a.entry_id
      join (
        select
          entry_id,
          max(submitted_at) max_t
        from
          b
        group by
          entry_id
      ) as bm on bm.entry_id = sub.entry_id
      left join c on sub.entry_id = c.entry_id
      join entries ent on sub.entry_id = ent.entry_id
    group by
      sub.user_id
  ) a
order by
  1,
  WRONG_ANS,
  2
提出情報
提出日時2024/04/16 12:28:39
コンテスト第3回 SQLコンテスト
問題順位計算
受験者orekwys
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
AC
86 MB
データパターン2
WA
85 MB