F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

The Third Cup is Free

Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4116    Accepted Submission(s): 1863


Problem Description
Panda and his friends were hiking in the forest. They came across a coffee bar inside a giant tree trunk.
Panda decided to treat everyone a cup of coffee and have some rest. Mr. Buck, the bartender greeted Panda and his animal friends with his antler. He proudly told them that his coffee is the best in the forest and this bar is a Michelin-starred bar, thats why the bar is called Starred Bucks.
There was a campaign running at the coffee bar: for every 3 cups of coffee, the cheapest one is FREE. After asking all his friends for their flavors, Panda wondered how much he need to pay.
 

Input
The first line of the input gives the number of test cases, T.
T test cases follow. Each test case consists of two lines. The first line contains one integer N, the number of cups to be bought.
The second line contains N integers $p_1, p_2, ¡¤ ¡¤ ¡¤ , p_N$ representing the prices of each cup of coffee.
 

Output
For each test case, output one line containing ¡°Case #x: y¡±, where x is the test case number (starting from 1) and y is the least amount of money Panda need to pay.

limits


$\bullet$ 1 ¡Ü T ¡Ü 100.
$\bullet$ 1 ¡Ü N ¡Ü $10^5$.
$\bullet$ 1 ¡Ü pi ¡Ü 1000.

 

Sample Input
2 3 1 2 3 5 10 20 30 20 20
 

Sample Output
Case #1: 5 Case #2: 80
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 09:31:43, Gzip enabled