ソースコード
with POINT_PER_ENTRY as (
    select
    	ENTRY_ID,
    	sum(POINT) as POINT
    from
    	SUBMISSIONS
    where 
    	CONTEST_ID = 2 and 
    	ENTRY_ID is not NULL
    group by 
    	ENTRY_ID
),
LAST_AC_TIME_PER_ENTRY as (
    select
    	ENTRY_ID,
    	max(SUBMITTED_AT) as LAST_AC
    from
    	SUBMISSIONS
    where 
    	CONTEST_ID = 2 and 
    	ENTRY_ID is not NULL and 
    	STATUS = 'AC'
    group by 
    	ENTRY_ID
),
WA_COUNT as (
    select
        A.ENTRY_ID,
        count(0) as WA_CNT
    from
    	SUBMISSIONS A
    inner join
        LAST_AC_TIME_PER_ENTRY B
    on
        A.CONTEST_ID = 2 and
        A.ENTRY_ID = B.ENTRY_ID and
    	A.STATUS = 'WA' and 
    	A.SUBMITTED_AT <= B.LAST_AC
    group by 
    	A.ENTRY_ID
)

select
*
from
(
select
    RANK() OVER(ORDER BY B.LAST_AC + C.WA_CNT * 300 DESC, B.LAST_AC asc) AS 'RANK',
    D.USER_ID as USER_ID,
    (B.LAST_AC + C.WA_CNT * 300) as POINT,
    B.LAST_AC as EX_TIME,
    C.WA_CNT as WRONG_ANS
from
    POINT_PER_ENTRY A
inner join
    LAST_AC_TIME_PER_ENTRY B
on
    A.ENTRY_ID = B.ENTRY_ID
inner join
    WA_COUNT C
on
    A.ENTRY_ID = C.ENTRY_ID
inner join
    ENTRIES D
on
    A.ENTRY_ID = D.ENTRY_ID
) DATA
order by
    RANK asc,
    WRONG_ANS asc,
    USER_ID asc


    
提出情報
提出日時2022/10/19 22:14:12
コンテスト第3回 SQLコンテスト
問題順位計算
受験者anpanudon
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量108 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
79 MB
データパターン2
WA
108 MB