1116 - I2P CS 2016 Chen HW12 Scoreboard

Time

2016/12/24 00:00:00 2016/12/30 23:59:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10880 Calculating calorie
11266 Query products

10880 - Calculating calorie   

Description

Anne is on a diet now so she wants to eat the set with the lowest calorie. You will be given N sets(1<=N<50) which contains the calorie of salad, main course , drink and dessert then you need to calculate the set of the lowest calorie and tell Anne which set should she eats.(All the sets have different total calorie.)

You need to store these information in structures:

 

For example, if there are 2 set, the first set is Meatball Marinara and the calorie of salad is 235, main course is 560, drink is 250 and dessert is 380. The other set is Spicy Italian and the calorie of salad is 125, main course is 389, drink is 320 and dessert is 150. Because the total calorie of Meatball Marinara is 235+560+250+380 = 1425 and the total calorie of Spicy Italian is 125+389+320+150 = 984, you need to return the number of set, which is index 1 in menu array and print the name “SpicyItalian”.

 

Note that

1.      This problem involves three files.

  • function.h: Function definition of calorie.
  • function.c: Function implementation of calorie.
  • main.c: A driver program to test your implementation.

You will be provided with main.c and function.h, and asked to implement function.c.

2.     For OJ submission:

       Step 1. Submit only your function.c into the submission block. (Please choose c compiler) 

       Step 2. Check the results and debug your program if necessary.

 

 

Hints:

function.h

main.c

 

Input

The first is number of N sets. For each case, the first is the number of the set(number will be in order, like 1 2 3 4 5....). The second line is the name of the set. The third line is the calorie of salad, main course(means main in structure Set), drink and dessert.

Output

The name with the lowest calorie. Note that you don’t need to print “\n” at the end.

Sample Input  Download

Sample Output  Download

Partial Judge Code

10880.c

Partial Judge Header

10880.h

Tags

contest 10401Contest



Discuss




11266 - Query products   

Description

Given a lot of product names and its price , you have to print out all the products which is beginning with the query string

from the lowest price to the highest price.

Note that :

1. All you have to do is to check whether the product name is beginning with the query string 

   If true , it's a match .  If not, it's not a match. 

   Ex: If the query string is "Apple" , then "AppleIphone7s" is a match and "SamsungNote7" isn't a match.

         Because "AppleIphone7s" is beginning with "Apple" , while "SamsungNote7" isn't.

2. Print out all the matches from the lowest price to the highest price.

3.There is at least 1 match in every test case.

4.The price of each product is different from others.

5. If you encounter TLE (Time Limit Exceed) , you can use "qsort" to speed up your program

 

 

Input

The first line contains an integer N , indicating the number of products. (2<=N<=100)

Each of the following N lines contains a product name and its price . (3<=length of name<=20)

The last line is the query string.

Output

Print out all the matches in this output format:

      printf("%s %d\n",product_name,price);

You should print out the matches from the lowest price to the highest price.

 

 

Sample Input  Download

Sample Output  Download

Tags




Discuss