Created
August 15, 2016 17:14
-
-
Save latte0119/5f346edd75b118ca0c720b49add18e03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
#define int long long | |
typedef vector<int>vint; | |
typedef pair<int,int>pint; | |
typedef vector<pint>vpint; | |
#define rep(i,n) for(int i=0;i<(n);i++) | |
#define reps(i,f,n) for(int i=(f);i<(n);i++) | |
#define all(v) (v).begin(),(v).end() | |
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++) | |
#define pb push_back | |
#define fi first | |
#define se second | |
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;} | |
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;} | |
const int mod=1000000007; | |
int N,W; | |
int w[200]; | |
int s[200]; | |
int dp[10001]; | |
signed main(){ | |
cin>>N>>W; | |
rep(i,N)cin>>w[i]; | |
sort(w,w+N); | |
rep(i,N)s[i]=w[i]+(i?s[i-1]:0); | |
if(s[N-1]<=W){ | |
cout<<1<<endl; | |
return 0; | |
} | |
dp[0]=1; | |
int ans=0; | |
for(int i=N-1;i>=0;i--){ | |
for(int j=W-s[i]+1;j<=W-s[i]+w[i];j++)if(j>=0)ans=(ans+dp[j])%mod; | |
for(int j=W-w[i];j>=0;j--)dp[j+w[i]]=(dp[j+w[i]]+dp[j])%mod; | |
} | |
cout<<ans<<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment