結果

問題 No.2378 Cards and Subsequences
ユーザー 👑 timitimi
提出日時 2023-06-11 10:47:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 346 ms / 2,000 ms
コード長 590 bytes
コンパイル時間 754 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 141,324 KB
最終ジャッジ日時 2023-09-28 21:38:27
合計ジャッジ時間 11,266 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
75,016 KB
testcase_01 AC 80 ms
75,028 KB
testcase_02 AC 79 ms
74,920 KB
testcase_03 AC 113 ms
78,076 KB
testcase_04 AC 117 ms
78,992 KB
testcase_05 AC 114 ms
78,284 KB
testcase_06 AC 134 ms
83,864 KB
testcase_07 AC 145 ms
86,200 KB
testcase_08 AC 149 ms
87,748 KB
testcase_09 AC 149 ms
89,536 KB
testcase_10 AC 123 ms
80,700 KB
testcase_11 AC 340 ms
140,748 KB
testcase_12 AC 316 ms
135,844 KB
testcase_13 AC 336 ms
141,000 KB
testcase_14 AC 322 ms
141,324 KB
testcase_15 AC 322 ms
140,932 KB
testcase_16 AC 315 ms
136,020 KB
testcase_17 AC 319 ms
140,880 KB
testcase_18 AC 317 ms
141,324 KB
testcase_19 AC 321 ms
140,920 KB
testcase_20 AC 322 ms
140,944 KB
testcase_21 AC 290 ms
135,580 KB
testcase_22 AC 292 ms
135,676 KB
testcase_23 AC 283 ms
135,652 KB
testcase_24 AC 284 ms
135,752 KB
testcase_25 AC 294 ms
135,736 KB
testcase_26 AC 343 ms
140,784 KB
testcase_27 AC 344 ms
141,172 KB
testcase_28 AC 344 ms
140,740 KB
testcase_29 AC 343 ms
141,000 KB
testcase_30 AC 346 ms
141,060 KB
testcase_31 AC 315 ms
135,776 KB
testcase_32 AC 201 ms
135,036 KB
testcase_33 AC 285 ms
135,708 KB
testcase_34 AC 291 ms
135,760 KB
testcase_35 AC 285 ms
135,572 KB
testcase_36 AC 287 ms
135,756 KB
testcase_37 AC 107 ms
77,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,K=map(int, input().split())
S=list(map(int, input().split()))
A=list(map(int, input().split()))
B=list(map(int, input().split()))
mod=998244353
dp=[[0]*(K+1) for _ in range(N+1)]
L=[-1 for _ in range(2001)]
cp=[[0]*(K+1) for _ in range(N+2)]
dp[0][0]=1;cp[0][0]=1
for i in range(N):
  a,b=A[S[i]-1],B[S[i]-1]
  for j in range(K+1):
    if j-a>=0:
      dp[i+1][j]+=cp[i][j-a]-cp[L[S[i]]][j-a]
      dp[i+1][j]%=mod
    if j-b>=0:
      dp[i+1][j]+=cp[i][j-b]-cp[L[S[i]]][j-b]
      dp[i+1][j]%=mod
    cp[i+1][j]=cp[i][j]+dp[i+1][j]
    cp[i+1][j]%=mod
  L[S[i]]=i
print(cp[-2][-1]%mod)
0