結果

問題 No.2616 中央番目の中央値
ユーザー ニックネームニックネーム
提出日時 2024-01-26 23:53:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 311 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 112,620 KB
最終ジャッジ日時 2024-01-26 23:53:17
合計ジャッジ時間 7,535 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 36 ms
53,460 KB
testcase_06 AC 36 ms
53,460 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 39 ms
53,460 KB
testcase_09 AC 37 ms
53,460 KB
testcase_10 AC 42 ms
59,340 KB
testcase_11 AC 44 ms
61,464 KB
testcase_12 AC 47 ms
61,720 KB
testcase_13 AC 60 ms
70,708 KB
testcase_14 AC 60 ms
72,756 KB
testcase_15 AC 67 ms
76,340 KB
testcase_16 AC 74 ms
77,276 KB
testcase_17 AC 79 ms
78,768 KB
testcase_18 AC 94 ms
81,480 KB
testcase_19 AC 128 ms
88,680 KB
testcase_20 AC 130 ms
88,680 KB
testcase_21 AC 217 ms
103,132 KB
testcase_22 AC 302 ms
112,572 KB
testcase_23 AC 299 ms
112,620 KB
testcase_24 AC 199 ms
112,620 KB
testcase_25 AC 198 ms
112,620 KB
testcase_26 AC 302 ms
112,620 KB
testcase_27 AC 304 ms
112,620 KB
testcase_28 AC 299 ms
112,620 KB
testcase_29 AC 301 ms
112,620 KB
testcase_30 AC 311 ms
112,620 KB
testcase_31 AC 292 ms
112,620 KB
testcase_32 AC 296 ms
112,620 KB
testcase_33 AC 296 ms
112,620 KB
testcase_34 AC 294 ms
112,620 KB
testcase_35 AC 298 ms
112,620 KB
testcase_36 AC 299 ms
112,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class BIT:
    def __init__(self,n):
        self.n = n; self.k = [0]*(n+1)
    def a(self,i,x):
        while i<=self.n: self.k[i] += x; i += i&-i
    def s(self,i):
        t = 0
        while i>0: t += self.k[i]; i -= i&-i
        return t
n = int(input()); mod = 998244353; fa = [1]*(n+1); fi = [1]*(n+1)
for i in range(1,n): fa[i+1] = fa[i]*(i+1)%mod
fi[n] = pow(fa[n],mod-2,mod)
for i in range(n,0,-1): fi[i-1] = fi[i]*i%mod
def cmb(n,r): return fa[n]*fi[n-r]%mod*fi[r]%mod if 0<=r<=n else 0
bit = BIT(n); x = 0; ans = 0
for i,v in enumerate(map(int,input().split())):
    ls = bit.s(v); ll = i-ls; rs = v-1-ls; rl = n-v-ll; bit.a(v,1)
    ans += cmb(ls+rl,ls)*cmb(ll+rs,ll)
print(ans%mod)
0