ソースコード
with w as (
select ENTRY_ID,sum(W1.WRONG_ANS) as WRONG_ANS, 300*sum(W1.WRONG_ANS) as pena
from (
select
s.ENTRY_ID,
s.PROBLEM_ID,
count(*) as WRONG_ANS
from
SUBMISSIONS s,
(
select 
s1.ENTRY_ID,
s1.CONTEST_ID,
s1.PROBLEM_ID,
MAX(s1.SUBMITTED_AT) as SUBMITTED_AT
from
SUBMISSIONS s1
where s1.STATUS='AC'
and s1.CONTEST_ID=2
and s1.ENTRY_ID is not null
group by 1,2,3
) s2
where s.ENTRY_ID=s2.ENTRY_ID
and s.CONTEST_ID=s2.CONTEST_ID
and s.PROBLEM_ID=s2.PROBLEM_ID
and s.SUBMITTED_AT < s2.SUBMITTED_AT
group by 1,2
) W1
group by 1
),
t as (
select
e.ENTRY_ID,
max(strftime('%s',s.SUBMITTED_AT) - strftime('%s',e.STARTED_AT)) as EX_TIME
from
ENTRIES e,
SUBMISSIONS s
where e.ENTRY_ID=s.ENTRY_ID
and e.CONTEST_ID=s.CONTEST_ID
and e.CONTEST_ID=2
and s.STATUS='AC'
group by 1
),
p as (
select
s.ENTRY_ID,
sum(s.POINT) as POINT
from
SUBMISSIONS s
where
s.CONTEST_ID=2
and s.ENTRY_ID is not null
group by 1
having POINT > 0
)
select 
rank() over( order by p.POINT desc,(t.EX_TIME+300*ifnull(w.WRONG_ANS,0))) as rank,
e.USER_ID,
p.POINT,
t.EX_TIME+ifnull(w.pena,0) as EX_TIME,
ifnull(w.WRONG_ANS,0) as WRONG_ANS
from
ENTRIES e
JOIN t ON e.ENTRY_ID=t.ENTRY_ID
JOIN p ON e.ENTRY_ID=p.ENTRY_ID
LEFT OUTER JOIN w on e.ENTRY_ID=w.ENTRY_ID
order by 1,5,2
提出情報
提出日時2022/10/20 22:56:29
コンテスト第3回 SQLコンテスト
問題順位計算
受験者KT04
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量77 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
76 MB
データパターン2
WA
77 MB