ソースコード
#include<bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 20171211;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll N,K,B;cin>>N>>K>>B;
ll A[N];for(ll i=0;i<N;i++)cin>>A[i];
ll dp[N+1][1<<N];
for(ll i=0;i<=N;i++)fill(dp[i],dp[i]+(1<<N),INF);
dp[0][0]=0;
for(ll t=0;t<N;t++){
for(ll S=1;S<1<<N;S++){
for(ll x=0;x<N;x++)if((S>>x)&1){
dp[t+1][S] = min(dp[t+1][S],dp[t+1][S^(1<<x)]+A[x]);
dp[t+1][S] = min(dp[t+1][S],((dp[t][S^(1<<x)]+B-1)/B)*B+A[x]);
}
}
}
ll ans=N;
for(ll t=0;t<=N;t++){
if(dp[t][(1<<N)-1]<=K*B){
ans = N-t;
}
}
cout<<ans<<endl;
return 0;
}