ソースコード
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, 4, 2;
提出情報
提出日時2022/10/19 21:28:41
コンテスト第3回 SQLコンテスト
問題順位計算
受験者matsuu
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量97 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
AC
97 MB
データパターン2
WA
96 MB