Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Paying Up : Practice question Wrong Answer..(Help please)

$
0
0

Hi

I have the following python code snippet to solve the Paying Up problem .

The tests pass as expected on my computer based on the sample input provided but when I upload the same I get a WA .

Please see the code below

from sys import stdin

T=int(stdin.readline())

for t in xrange(T):

    notes,demand=map(int,stdin.readline().split())
    sum=0
    wallet=list()
    filter_wallet=list()

    for n in xrange(notes):
        i=int(stdin.readline())
        wallet.append(i)

    wallet.sort(reverse=True)
    filter_wallet=filter(lambda x: x <=demand ,wallet)

    for c in filter_wallet:

        if (sum + c )<= demand:
            sum=sum + c



    print "Yes" if sum == demand else  "No"

Am I making any mistake ..?


Viewing all articles
Browse latest Browse all 40121

Trending Articles