```cpp
#include<bits/stdc++.h>
using namespace std;
int n,h,delta,a,t,maxn[2005],dp[2005][2005],b[2005][2005];
int main(){
cin>>n>>h>>delta;
for(int i=1;i<=n;i++){
cin>>a;
for(int j=1;j<=a;j++){
cin>>t;
b[t][i]++;
}
}
for(int i=h;i>=1;i--){
for(int j=1;j<=n;j++)
if(i+delta<=h) dp[i][j]=max(dp[i+1][j],maxn[i+delta])+b[i][j];
else dp[i][j]=dp[i+1][j]+b[i][j];
for(int j=1;j<=n;j++) maxn[i]=max(maxn[i],dp[i][j]);
}
cout<<maxn[1];
return 0;
}
```
by zrl123456 @ 2024-01-14 19:57:02