結果

問題 No.2625 Bouns Ai
ユーザー hirayuu_ychirayuu_yc
提出日時 2024-02-09 21:26:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 505 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 221,128 KB
最終ジャッジ日時 2024-02-09 21:27:04
合計ジャッジ時間 9,236 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
62,072 KB
testcase_01 AC 44 ms
61,304 KB
testcase_02 AC 63 ms
69,732 KB
testcase_03 AC 157 ms
216,036 KB
testcase_04 AC 321 ms
216,920 KB
testcase_05 AC 159 ms
216,724 KB
testcase_06 AC 159 ms
216,848 KB
testcase_07 AC 159 ms
216,724 KB
testcase_08 AC 163 ms
218,900 KB
testcase_09 AC 156 ms
215,996 KB
testcase_10 AC 305 ms
216,920 KB
testcase_11 AC 50 ms
65,112 KB
testcase_12 AC 401 ms
218,968 KB
testcase_13 AC 478 ms
221,048 KB
testcase_14 AC 413 ms
221,100 KB
testcase_15 AC 400 ms
221,024 KB
testcase_16 AC 404 ms
221,112 KB
testcase_17 AC 401 ms
221,040 KB
testcase_18 AC 416 ms
221,112 KB
testcase_19 AC 418 ms
221,100 KB
testcase_20 AC 422 ms
221,128 KB
testcase_21 AC 402 ms
221,024 KB
testcase_22 AC 505 ms
221,076 KB
testcase_23 AC 457 ms
221,048 KB
testcase_24 AC 476 ms
221,076 KB
testcase_25 AC 399 ms
221,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit((1<<19)-1)
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
input=sys.stdin.buffer.readline

MOD=998244353
sc=100000
N=int(input())
A=[0]+list(map(int,input().split()))
dp=[0]*(sc+1)
dp[0]=1
for i in range(N):
    ndp=[0]*(sc+1)
    ans=0
    for j in range(sc+1):
        if A[i+1]+j>sc:
            break
        if A[i]<=A[i+1]:
            ans+=dp[j]
        else:
            if j-(A[i]-A[i+1])>=0:
                ans+=dp[j-(A[i]-A[i+1])]
        ans%=MOD
        ndp[j]=ans
    dp=ndp
print(sum(dp)%MOD)
0