Problem:
Score : 200 points

Problem Statement

There are N children, numbered 1, 2, ..., N.

Snuke has decided to distribute x sweets among them.
He needs to give out all the x sweets, but some of the children may get zero sweets.

For each i (1 \leq i \leq N), Child i will be happy if he/she gets exactly a_i sweets.
Snuke is trying to maximize the number of happy children by optimally distributing the sweets.
Find the maximum possible number of happy children.

Constraints

All values in input are integers.

2 \leq N \leq 100

1 \leq x \leq 10^9

1 \leq a_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N x
a_1 a_2 ... a_N

Output

Print the maximum possible number of happy children.

Sample Input 1

3 70
20 30 10

Sample Output 1

2

One optimal way to distribute sweets is (20, 30, 20).

Sample Input 2

3 10
20 30 10

Sample Output 2

1

The optimal way to distribute sweets is (0, 0, 10).

Sample Input 3

4 1111
1 10 100 1000

Sample Output 3

4

The optimal way to distribute sweets is (1, 10, 100, 1000).

Sample Input 4

2 10
20 20

Sample Output 4

0

No children will be happy, no matter how the sweets are distributed.

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<cctype>
using namespace std;
const long long inf=(1ll<<60);
const double eps=1e-10;
const double pi=acos(-1.0);
inline long long read(){
	long long x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
const int N=2010;
long long n,x,ans=inf;
long long id[N],f[N][N];
int main(){
  n=read();x=read();
  for(int i=0;i<n;i++)id[i]=read();
  memset(f,127,sizeof(f));
  f[n][0]=0;
  for(int i=n-1;i>=0;i--)
  for(int j=1;j<=n;j++){
    long long v=n-i-j-1;
    if(v>=0)f[i][j]=min(f[i][j],f[i+1][j]+x+id[i]*((v/j)*2+5));
    f[i][j]=min(f[i][j],f[i+1][j-1]+x*2+id[i]*5);
  }
  for(int j=1;j<=n;j++)
  ans=min(ans,f[0][j]);
  printf("%lld\n",ans);
  return 0;
}