ソースコード
WITH A as (
  SELECT
    distinct
    strftime('%s', sub.SUBMITTED_AT) - strftime('%s', en.STARTED_AT) time_diff
    , sub.POINT
    , sub.USER_ID
    , count(sub_wa.status != 'AC') over (partition by sub.SUBMIT_ID) wrong
  FROM
    ENTRIES en
      INNER JOIN SUBMISSIONS sub ON en.ENTRY_ID = sub.ENTRY_ID and en.CONTEST_ID = sub.CONTEST_ID and sub.STATUS = 'AC' and en.CONTEST_ID = 2 
      LEFT JOIN SUBMISSIONS sub_wa ON en.ENTRY_ID = sub_wa.ENTRY_ID and sub.PROBLEM_ID = sub_wa.PROBLEM_ID and sub_wa.STATUS != 'AC' and sub_wa.SUBMITTED_AT < sub.SUBMITTED_AT
), B as (
  SELECT
    max(A.time_diff) + sum(A.wrong) * 300 EX_TIME
    , A.USER_ID USER_ID
    , sum(A.POINT) POINT
    , sum(A.wrong) WRONG_ANS
  FROM
    A
  GROUP BY
    A.USER_ID
)
SELECT
  RANK() over (order by POINT desc, EX_TIME) RANK
  , USER_ID
  , POINT
  , EX_TIME
  , WRONG_ANS
FROM
  B
ORDER BY
  RANK, WRONG_ANS, USER_ID
;
提出情報
提出日時2022/10/23 22:00:34
コンテスト第3回 SQLコンテスト
問題順位計算
受験者udo
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
81 MB
データパターン2
AC
81 MB