結果

問題 No.2792 Security Cameras on Young Diagram
ユーザー rlangevinrlangevin
提出日時 2024-06-21 21:56:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 92,792 KB
最終ジャッジ日時 2024-06-24 18:44:48
合計ジャッジ時間 2,327 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
62,276 KB
testcase_01 AC 46 ms
62,632 KB
testcase_02 AC 46 ms
62,228 KB
testcase_03 AC 46 ms
62,440 KB
testcase_04 AC 47 ms
62,804 KB
testcase_05 AC 48 ms
63,128 KB
testcase_06 AC 47 ms
63,352 KB
testcase_07 AC 51 ms
63,792 KB
testcase_08 AC 48 ms
62,916 KB
testcase_09 AC 46 ms
63,088 KB
testcase_10 AC 47 ms
63,488 KB
testcase_11 AC 47 ms
63,436 KB
testcase_12 AC 78 ms
84,688 KB
testcase_13 AC 71 ms
81,564 KB
testcase_14 AC 78 ms
84,456 KB
testcase_15 AC 65 ms
79,220 KB
testcase_16 AC 74 ms
85,712 KB
testcase_17 AC 76 ms
87,860 KB
testcase_18 AC 63 ms
77,940 KB
testcase_19 AC 69 ms
79,576 KB
testcase_20 AC 68 ms
80,772 KB
testcase_21 AC 45 ms
63,120 KB
testcase_22 AC 44 ms
62,232 KB
testcase_23 AC 86 ms
92,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
mod = 998244353

n = 2*10**5+5
fact = [1] * (n + 1)
invfact = [1] * (n + 1)
for i in range(1, n):
    fact[i + 1] = ((i+1) * fact[i]) % mod
invfact[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % mod

def comb(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return fact[n] * invfact[r] * invfact[n - r] % mod

A.append(0)
now = A[0]
ans = 0
for i in range(1, N + 1):
    while now > A[i]:
        ans += comb(i - 1 + now, i - 1)
        ans %= mod
        now -= 1 
print((ans+1)%mod)
0