Mike and Task Packages WA in Python

Hi,

I coded this solution for MIKE2:

from __future__ import division
def read_mapped(func=lambda x:x):
    return map(func, raw_input().split(" "))
def read_array(N, func):
    l = []
    for i in xrange(N):
        l.append(func(raw_input()))
    return l
def read_int():
    return int(raw_input())
def read_str():
    return raw_input()
def read_float():
    return float(raw_input())

n, x = read_mapped(int)
a = read_mapped(int)
a = sorted(a)
successes = 0
fails = 0
passed = 0

for i in range(len(a)):
    if x>=a[i]:
        x -= a[i]
        successes += 1
        passed += 1
    elif x>(a[i]/2):
        x = 0
        passed += 1
        break
    else:
        fails = len(a) - passed
        break

print fails, successes

But it doesn’t work beyond two subtasks as seen here.
Please help me understand what I’m doing wrong, and what exactly is greedy programming.
P.S: The read_int read_str stuff is just boilerplate code for problems in Algorithmic competitions.

Thanks in advance

@admin help

//