Programming contests

Magas szintű programozási nyelvek 1, gyakorló feladatsor, 2012. március 20.

March 20, 2012 3:00 PM – April 21, 2012 12:00 AM

Tariff Plan

Ampang Communications & Mobile (ACM) provides telecom services for various types of users. Since the people of Ampang are quite talkative, they are always seeking for packages that are best suited for them. To have an edge over their competitors, ACM provides various packages. Two of the most popular packages are:

  • Mile
  • Juice

Mile charges every 30 seconds at a rate of 10 cents. That means if you talk for 29 seconds or less, you will be charged with 10 cents. If you talk for 30 to 59 seconds, you will be charged with 20 cents and so on.

Juice charges every 60 seconds at a rate of 15 cents. That means if you talk for 59 seconds or less, you will be charged with 15 cents. Similarly, if you talk for 60 seconds to 119 seconds, you will be charged with 30 cents and so on.

Given a list of call durations, can you determine the package that is cheaper?

Input Specification

The first line of input is an integer T (T < 50) that denotes the total number of test cases. Each case starts with a line containing an integer N (0 < N < 20). The next line gives a list of N call durations (in second). Each call duration is an integer in the range [1, 2000]. Consecutive integers are separated by a single space character.

Output Specification

For each case, output the case number first. Then output the name of the cheaper package followed by the corresponding cost in cents. If both package gives the same total cost, then output both the names (Mile preceding Juice) followed by the cost. Look at the output for sample input for details.

Sample Input

  1. 3
  2. 2
  3. 61 10
  4. 3
  5. 40 40 40
  6. 2
  7. 60 65
download as text file

Output for Sample Input

  1. Case 1: Mile 40
  2. Case 2: Juice 45
  3. Case 3: Mile Juice 60
download as text file

Illustration: in Case 1 Mile is 30 + 10 = 40 and Juice is 30 + 15 = 45, in Case 2 Mile is 20 + 20 + 20 = 60 and Juice is 15 + 15 + 1 5 =45, and finally in Case 3 Mile is 30 + 30 = 60 and Juice is 30 + 30 = 60.

University of Debrecen; Faculty of Informatics; v. 03/01/2019