結果

問題 No.2792 Security Cameras on Young Diagram
ユーザー ニックネームニックネーム
提出日時 2024-06-21 22:03:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 416 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 29,944 KB
最終ジャッジ日時 2024-06-24 18:44:55
合計ジャッジ時間 3,811 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,752 KB
testcase_01 AC 32 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 33 ms
10,880 KB
testcase_04 AC 34 ms
10,880 KB
testcase_05 AC 32 ms
10,880 KB
testcase_06 AC 33 ms
10,880 KB
testcase_07 AC 33 ms
11,008 KB
testcase_08 AC 33 ms
10,880 KB
testcase_09 AC 33 ms
10,752 KB
testcase_10 AC 33 ms
11,008 KB
testcase_11 AC 33 ms
11,008 KB
testcase_12 AC 254 ms
24,488 KB
testcase_13 AC 216 ms
22,104 KB
testcase_14 AC 247 ms
24,032 KB
testcase_15 AC 196 ms
20,480 KB
testcase_16 AC 251 ms
24,948 KB
testcase_17 AC 286 ms
27,664 KB
testcase_18 AC 187 ms
19,840 KB
testcase_19 AC 186 ms
19,712 KB
testcase_20 AC 228 ms
21,760 KB
testcase_21 AC 32 ms
10,752 KB
testcase_22 AC 31 ms
10,752 KB
testcase_23 AC 321 ms
29,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))+[-1]
nmax = n+a[0]; mod = 998244353; fa = [1]*(nmax+1); fi = [1]*(nmax+1)
for i in range(1,nmax): fa[i+1] = fa[i]*(i+1)%mod
fi[nmax] = pow(fa[nmax],mod-2,mod)
for i in range(nmax,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
x = 0
for i in range(n):
    for j in range(a[i],a[i+1],-1): x += cmb(i+j,i)
print(x%mod)
0