コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
WITH
Calc_MAX_SUB
AS
(
SELECT
USER_ID
,PROBLEM_ID
,ENTRY_ID
,SUBMITTED_AT
,STATUS
FROM SUBMISSIONS
WHERE ENTRY_ID IS NOT NULL AND STATUS = 'AC' AND CONTEST_ID = 2
ORDER BY
USER_ID
,PROBLEM_ID
,SUBMITTED_AT
)
,
Calc_MAX
AS
(
SELECT
USER_ID
,MAX(SUBMITTED_AT) AS MAX_AT
FROM Calc_MAX_SUB
GROUP BY
USER_ID
)
,
Make_TABLE
AS
(
SELECT
SUB.*
,ENT.*
,CM.*
,MS.*
,CASE
WHEN SUB.STATUS = 'AC' AND SUB.SUBMITTED_AT = CM.MAX_AT THEN STRFTIME('%s',SUB.SUBMITTED_AT) - STRFTIME('%s',ENT.STARTED_AT)
WHEN SUB.STATUS = 'AC' AND SUB.SUBMITTED_AT <> CM.MAX_AT THEN 0
ELSE 300 END AS EXAM_AT
FROM SUBMISSIONS AS SUB
LEFT JOIN ENTRIES AS ENT on SUB.USER_ID = ENT.USER_ID AND SUB.ENTRY_ID = ENT.ENTRY_ID
LEFT JOIN Calc_MAX AS CM on SUB.USER_ID = CM.USER_ID
LEFT JOIN Calc_MAX_SUB AS MS on SUB.USER_ID = MS.USER_ID AND SUB.PROBLEM_ID = MS.PROBLEM_ID
WHERE SUB.CONTEST_ID = 2 AND SUB.ENTRY_ID IS NOT NULL AND SUB.SUBMITTED_AT <= CM.MAX_AT AND MS.PROBLEM_ID IS NOT NULL
ORDER BY
SUB.USER_ID
,SUB.PROBLEM_ID
,SUB.SUBMITTED_AT
)
,
Ranking_TABLE
AS
(
SELECT
RANK() OVER (ORDER BY POINT DESC, EX_TIME, WRONG_ANS) AS RANK
,USER_ID
,POINT
,EX_TIME
,WRONG_ANS
FROM
(
SELECT
USER_ID
,SUM(POINT) AS POINT
,SUM(EXAM_AT) AS EX_TIME
,SUM(CASE WHEN STATUS = 'AC' THEN 0 ELSE 1 END) AS WRONG_ANS
FROM Make_TABLE
GROUP BY
USER_ID
)
)
SELECT * FROM Ranking_TABLE;
提出情報
提出日時 | 2024/05/31 09:37:05 |
コンテスト | 第3回 SQLコンテスト |
問題 | 順位計算 |
受験者 | satoru |
状態 (詳細) | WA (Wrong Answer: 誤答) |
メモリ使用量 | 84 MB |
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
WA
84 MB