Public submissions
Source code of every submission to this problem in this contest will be visible for everyone since 4012-10-16 21:00:00.

TECHOFES - INVITATION FOR TECHOFES

Problem Statement:

You are going to invite chief guests for Techofes. There are n guests. You are given the cost required and the popularity of each chief guest. Among the n guests, you can invite any number of guests. But for inviting a guest, you have to pay his required cost. The expected number of audience is the sum of popularity of all the chosen guests. You only have M amount of money in hand. Find the maximum expected number of audience.

Input:

The first line consists of an integer t, the number of test cases. For each test case { The first line consists of 2 integers n and M – the number of guests and the money in hand respectively. Then n lines follows, each line contains two integers - the cost and popularity of each guest. }


Output:

For each test case find the maximum expected number of audience.

Input Constraints:

1<=t<=10
1<=n<=20
0<=cost,popularity<=1000
0<=M<=20000

Note that some chief guests may have no cost

Example:

Sample Input: (blank lines just for clarity)

3

2 8

1 9

5 7

 

2 2

2 14

2 12

 

5 9

9 1

6 4

7 15

3 12

9 5

 

Sample Output:

16

14

16


Added by:cegprakash
Date:2012-10-14
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:ADA95 ASM32 GAWK C CSHARP C++ 4.3.2 CPP14-CLANG C99 CLPS CLOJURE LISP sbcl LISP clisp D-CLANG ERL FSHARP FORTRAN GO HASK ICON ICK JS-RHINO JS-MONKEY LUA NICE NIM NODEJS OCAML PAS-FPC PERL PERL6 PHP PICO PIKE PRLG-swi PYTHON PYPY PYTHON3 RUBY SCM guile SCM qobi SED TCL VB.NET WHITESPACE
Public source code since: 4012-10-16 21:00:00

hide comments
2018-07-04 12:52:00
no special cases just simple b********g
2012-10-16 16:54:46 cegprakash
The test cases are correct. There are few corner cases such as M=0 and cost=0. Sorry, cannot provide more test cases.

Last edit: 2012-10-16 21:36:41
2012-10-16 16:52:25 sandhya
why am i getting WA??? i think my solution is right...can u give more test cases??
2012-10-16 16:48:18 shankari
ok............:)
2012-10-16 16:12:56 cegprakash
No
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.