提交时间:2022-08-18 11:16:03
运行 ID: 55474
#include<bits/stdc++.h> using namespace std; const int M=1e9+7; typedef long long ll; int n,m,k,wro[503],f[503][73][453]; int dfs(int peo,int hom,int wr){ if(f[peo][hom][wr]) return f[peo][hom][wr]; ll sum=0; for(int i=peo;i<=n;++i) { if(wr+wro[i]>k) break; if(hom+1==m) { ++sum; if(sum>M) sum-=M; } else { sum+=dfs(i,hom+1,wr+wro[i]); if(sum>M) sum-=M; } } f[peo][hom][wr]=sum; return sum; } int main(){ scanf("%d%d%d",&n,&m,&k); for(int i=1;i<=n;++i) scanf("%d",&wro[i]); sort(wro+1,wro+1+n); cout<<dfs(1,0,0)<<'\n'; return 0; }