Help the soldier
All submissions for this problem are available.
Igor, a famous russian soldier, must go to war. His superiors allowed him to buy his own equipment. He must buy 6 items: a helmet, bulletproof vest, trousers, boots, tunic and firearm. This items are represented with numbers from 1 to 6.
There are N (6 < N < 101) items of these 6 types. Each item is characterized by its price p[i] (in rublas) and is quality q[i]. Igor has a total of T (0 < T < 1001) rublas and he wants to maximize the total quality of his equipment. The total quality is the quality of the item with the lowest quality. Help him.
On the first line there are two integers: number of items for sale (N) and total rublas Igor has (T). Subsequent lines contain 3 integers: type (t) (from 1 to 6) price (> 0) and quality.
Output the total quality.
Input: 7 53 5 8 2 2 4 8 6 8 13 1 13 12 4 5 1 3 2 7 3 13 5 Output: 1 Note: If there is no answer, output 0. There can be less than 6 items.
|Time Limit:||0.1 sec|
|Source Limit:||2048 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, TCL, kotlin, TEXT, SCM chicken, PYP3, CLOJ, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.