結果

問題 No.2616 中央番目の中央値
ユーザー 👑 p-adicp-adic
提出日時 2023-12-19 18:48:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 633 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 57,712 KB
最終ジャッジ日時 2023-12-21 23:47:31
合計ジャッジ時間 10,516 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,240 KB
testcase_01 AC 32 ms
10,240 KB
testcase_02 AC 49 ms
10,240 KB
testcase_03 AC 29 ms
10,240 KB
testcase_04 AC 31 ms
10,240 KB
testcase_05 AC 30 ms
10,240 KB
testcase_06 AC 29 ms
10,240 KB
testcase_07 AC 29 ms
10,240 KB
testcase_08 AC 29 ms
10,240 KB
testcase_09 AC 31 ms
10,240 KB
testcase_10 AC 33 ms
10,240 KB
testcase_11 AC 35 ms
10,240 KB
testcase_12 AC 40 ms
10,368 KB
testcase_13 AC 61 ms
10,752 KB
testcase_14 AC 84 ms
11,264 KB
testcase_15 AC 144 ms
12,288 KB
testcase_16 AC 310 ms
14,456 KB
testcase_17 AC 450 ms
16,472 KB
testcase_18 AC 743 ms
20,420 KB
testcase_19 AC 1,635 ms
31,268 KB
testcase_20 AC 1,611 ms
31,268 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

I,R=input,range
N=int(I())
X=list(map(int,I().split()))
a=0
P=998244353
e=[0,1]
for i in R(2,N+1):e+=[P-P//i*e[P%i]%P]
f=[1]
for i in R(N):f+=[f[-1]*(i+1)%P]
g=[1]
for i in R(N):g+=[g[-1]*e[i+1]%P]
def B(i,t,F):
	i+=1
	while i<=N:F[i],i=F[i]+t,i+(i&-i)
def M(r,F):
	a=0
	i=min(r+1,N)
	while i:a,i=a+F[i],i-(i&-i)
	return a
F=[[0]*(N+1)for i in R(2)]
def A(l,r,t):
	B(l,-(l-1)*t,F[0]),B(r+1,r*t,F[0]),B(l,t,F[1]),B(r+1,-t,F[1])
def L(r):
	return M(r,F[0])+r*M(r,F[1])
def S(l,r):
	return L(r)-L(l-1)
for i in R(N):
	x=S(X[i]-1,X[i]-1)
	a+=f[2*x+N-X[i]-i]*g[x]*g[x+N-X[i]-i]*f[X[i]-1+i-2*x]*g[i-x]*g[X[i]-1-x]
	A(X[i],N-1,1)
print(a%P)
0