ソースコード
with T as (
  select
    S.SUBMIT_ID,
    S.CONTEST_ID,
    S.PROBLEM_ID,
    S.USER_ID,
    S.ENTRY_ID,
    E.STARTED_AT,
    S.SUBMITTED_AT,
    S.STATUS,
    S.POINT
  from SUBMISSIONS S
    inner join ENTRIES E on S.CONTEST_ID = E.CONTEST_ID and S.ENTRY_ID = E.ENTRY_ID
  where S.CONTEST_ID = '2'
), TRGT as (
  select
    *,
    strftime('%s', SUBMITTED_AT) - strftime('%s', STARTED_AT) as diff_sec
  from T
  where exists (
    select *
    from T T2
    where T.USER_ID = T2.USER_ID
      and T.PROBLEM_ID = T2.PROBLEM_ID
      and T2.STATUS = 'AC'
      and T.SUBMITTED_AT <= T2.SUBMITTED_AT)
), ANS as (
  select
    1 as RANK,
    TRGT.USER_ID,
    sum(TRGT.POINT) as POINT,
    case when T3.cnt is null then 0 else T3.cnt end as WRONG_ANS,
    T4.diff_sec + (300 * case when T3.cnt is null then 0 else T3.cnt end) as EX_TIME
  from TRGT
    left outer join (select ENTRY_ID, count(*) as cnt from TRGT where STATUS != 'AC' group by ENTRY_ID) T3 on TRGT.ENTRY_ID = T3.ENTRY_ID
    left outer join (select ENTRY_ID, max(diff_sec) diff_sec from TRGT group by ENTRY_ID) T4 on TRGT.ENTRY_ID = T4.ENTRY_ID
  group by TRGT.USER_ID
)
select
  RANK,
  USER_ID,
  POINT,
  WRONG_ANS,
  EX_TIME
from ANS
order by POINT desc, EX_TIME
;
提出情報
提出日時2022/10/20 00:05:40
コンテスト第3回 SQLコンテスト
問題順位計算
受験者uso800
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量97 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
95 MB
データパターン2
WA
97 MB