ソースコード
WITH TT AS (
SELECT
  USER_ID,
  SUM(POINT) AS POINT,
  strftime("%s", MAX(SUBMITTED_AT))-strftime("%s", STARTED_AT)+SUM(CASE STATUS WHEN 'WA' THEN 300 ELSE 0 END) AS EX_TIME,
  SUM(CASE STATUS WHEN 'WA' THEN 1 ELSE 0 END) AS WRONG_ANS
FROM SUBMISSIONS S
JOIN ENTRIES USING (ENTRY_ID,USER_ID,CONTEST_ID)
WHERE CONTEST_ID=2 AND EXISTS(
  SELECT 1 FROM SUBMISSIONS WHERE STATUS='AC' AND S.CONTEST_ID=CONTEST_ID AND S.PROBLEM_ID=PROBLEM_ID AND S.USER_ID=USER_ID AND S.ENTRY_ID=ENTRY_ID AND S.SUBMITTED_AT<=SUBMITTED_AT
)
GROUP BY USER_ID HAVING POINT > 0
)
SELECT
  RANK() OVER (ORDER BY POINT DESC, EX_TIME) AS RANK,
  USER_ID, POINT, EX_TIME, WRONG_ANS
FROM TT
ORDER BY 1, 5, 2;
提出情報
提出日時2022/10/19 21:30:24
コンテスト第3回 SQLコンテスト
問題順位計算
受験者matsuu
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量97 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
97 MB
データパターン2
AC
96 MB