結果

問題 No.2616 中央番目の中央値
ユーザー ニックネームニックネーム
提出日時 2024-01-26 23:18:24
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 820 bytes
コンパイル時間 451 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 88,532 KB
最終ジャッジ日時 2024-01-26 23:18:34
合計ジャッジ時間 8,893 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 42 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 42 ms
59,208 KB
testcase_10 AC 57 ms
68,772 KB
testcase_11 AC 60 ms
68,772 KB
testcase_12 AC 66 ms
70,832 KB
testcase_13 AC 98 ms
76,248 KB
testcase_14 AC 133 ms
76,372 KB
testcase_15 AC 317 ms
76,756 KB
testcase_16 AC 1,073 ms
77,692 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
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 #

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; x = y = 0; bit.a(v,1)
    for j in range(1,min(ls,rl)+1): x += cmb(ls,j)*cmb(rl,j)%mod
    for j in range(1,min(ll,rs)+1): y += cmb(ll,j)*cmb(rs,j)%mod
    ans += (x+1)*(y+1)
print(ans%mod)
0