ソースコード
with st as (select 
user_id, entry_id, started_at from entries where contest_id = 2
)
, ss as (select
submissions.*, st.started_at from submissions join st on submissions.entry_id = st.entry_id
)
, points as (
select user_id, sum(point) as sump from ss
group by USER_ID
)
, ex as (
select *, strftime('%s', submitted_at) - strftime('%s', started_at) as diff
from ss
where status = 'AC'
group by user_id, problem_id
)
, ex2 as (
select USER_ID, max(diff) as sumdiff from ex group by USER_ID
)
, wa as (
select *
from ss
where status = 'WA' and exists
(select 1 from ex where ss.user_id = ex.user_id and ss.problem_id = ex.problem_id and ss.submitted_at < ex.submitted_at)
)
, wa2 as (select user_id, count(1) as cnt from wa group by user_id)
, fin as (select points.user_id as USER_ID, points.sump as POINT, ex2.sumdiff + ifnull(wa2.cnt, 0) * 300 as EX_TIME, ifnull(wa2.cnt, 0) as WRONG_ARGS from points join ex2 on points.user_id = ex2.user_id left join wa2 on points.user_id = wa2.user_id)
, fin2 as (select *, rank() over (order by POINT desc, EX_TIME) as RANK from fin)
select RANK, USER_ID, POINT, EX_TIME, WRONG_ARGS as WRONG_ANS from fin2
order by RANK, WRONG_ARGS, USER_ID
-- select * from wa2
-- select * from ex2
提出情報
提出日時2024/04/28 17:07:13
コンテスト第3回 SQLコンテスト
問題順位計算
受験者daku10
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
WA
85 MB