New Year's '15 P2 - Food Selection

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Inaho has been invited to Asseylum's party dedicated to celebrating the new year! Being very welcoming, Asseylum bought a lot of food for Inaho. Sadly, Inaho wishes to stay healthy and sets limits on his food intake. Having so much food to choose from, Inaho just couldn't process all this food, and decides to ask you to help him by filtering out only the food that he can eat from the menu.

Inaho limits himself to not exceed a certain amount of calories, fat, and sodium intake per serving. Luckily, Asseylum's menu has all the nutrition information that you need.

Input Specification

The first line of the input contains three integers: C, F, and S, the caloric, fat, and sodium limit that Inaho set for himself, respectively, such that 0 \le C, F, S \le 1\,000. The next line contains the integer N, the number of items on the menu, such that 1 \le N \le 100. The i^\text{th} line that follows contain integers X_i, C_i, F_i, and S_i, where X_i is the number of servings in the food, and the rest are the amount of calories, fat, and sodium in the food, respectively, such that 0 < X_i \le 10, 0 \le C_i, F_i, S_i \le 10\,000. On the same line, following S_i after a space, is the name of the food item, which may contain spaces, but no longer than 50 characters.

Output Specification

For the i^\text{th} food item, output its name if and only if \dfrac{C_i}{X_i} \le C, \dfrac{F_i}{X_i} \le F, and \dfrac{S_i}{X_i} \le S.

Sample Input

770 130 250
5
10 1210 3721 4399 Philly Cheese Steak
7 20 3433 5632 Portobello Sandwich
9 3241 1009 198 Shrimp Cocktail
8 3542 744 40 Hickory Bourbon Salmon
2 605 1062 128 Shrimp Po' Boy Flatbread

Sample Output

Shrimp Cocktail
Hickory Bourbon Salmon

Comments

There are no comments at the moment.