結果

問題 No.2616 中央番目の中央値
ユーザー ニックネームニックネーム
提出日時 2024-01-26 23:52:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 695 bytes
コンパイル時間 552 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 60,668 KB
最終ジャッジ日時 2024-01-26 23:52:59
合計ジャッジ時間 37,529 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,112 KB
testcase_01 AC 30 ms
10,112 KB
testcase_02 AC 30 ms
10,112 KB
testcase_03 AC 29 ms
10,112 KB
testcase_04 AC 29 ms
10,112 KB
testcase_05 AC 29 ms
10,112 KB
testcase_06 AC 29 ms
10,112 KB
testcase_07 AC 31 ms
10,112 KB
testcase_08 AC 30 ms
10,112 KB
testcase_09 AC 30 ms
10,112 KB
testcase_10 AC 31 ms
10,112 KB
testcase_11 AC 32 ms
10,240 KB
testcase_12 AC 33 ms
10,240 KB
testcase_13 AC 43 ms
10,624 KB
testcase_14 AC 54 ms
11,008 KB
testcase_15 AC 77 ms
11,904 KB
testcase_16 AC 133 ms
13,440 KB
testcase_17 AC 187 ms
14,976 KB
testcase_18 AC 334 ms
18,628 KB
testcase_19 AC 639 ms
27,016 KB
testcase_20 AC 672 ms
27,016 KB
testcase_21 AC 1,399 ms
42,772 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 AC 1,567 ms
59,128 KB
testcase_25 AC 1,566 ms
59,128 KB
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
権限があれば一括ダウンロードができます

ソースコード

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