Food Selection

View as PDF

Submit solution

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

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Inaho has been invited to Asseylum's party dedicated to celebrate the new year! Being very welcoming, Asseylum bought a lot of food for Inaho. Sadly, Inaho wishes to stay healthy and sets limits of his food intake. Having so much food to choose from, Inaho just couldn't process all these 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^{th} line that follows contain integers X_i, C_i, F_i, and S_i, where X_i is the amount 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^{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


  • 0
    Oppenheimer  commented on Jan. 2, 2015, 1:41 p.m.

    I don't know if I'm allowed to ask this but I am confused by this error message: "Floor o' Floating Points (Bad Division Special)" I'm not sure what this means - any clarification would be much appreciated.


    • 0
      quantum  commented on Jan. 2, 2015, 1:56 p.m.

      That's just a dish, not an error message.


    • -3
      Oppenheimer  commented on Jan. 2, 2015, 1:51 p.m.

      Never mind guys, I figured it out.