Quantcast
Viewing all articles
Browse latest Browse all 39796

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

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 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>