hdu 5999 The Third Cup is Free
来源:互联网 发布:形容男生的网络词语 编辑:程序博客网 时间:2024/05/01 00:03
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 p1,p2,⋅⋅⋅,pN 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
∙ 1 ≤ T ≤ 100.
∙ 1 ≤ N ≤ 105.
∙ 1 ≤ pi ≤ 1000.
Sample Input
2
3
1 2 3
5
10 20 30 20 20
Sample Output
Case #1: 5
Case #2: 80
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 p1,p2,⋅⋅⋅,pN 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
∙ 1 ≤ T ≤ 100.
∙ 1 ≤ N ≤ 105.
∙ 1 ≤ pi ≤ 1000.
Sample Input
2
3
1 2 3
5
10 20 30 20 20
Sample Output
Case #1: 5
Case #2: 80
水一发 2017年的首A:题意:n个咖啡中,每3杯中最便宜的一杯可以免费,求最少需要付多少钱。
#include <iostream>#include<stdio.h>#include<algorithm>#define siz 100005using namespace std;int a[siz];bool cmp(int a,int b){return a>b;}int main(){ int T,ans,n,t=1; cin>>T; while(T--) { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); sort(a+1,a+n+1,cmp); ans = 0; for(int i=1;i<=n;i++) { if(i%3==0) continue; ans+=a[i]; } cout<<"Case #"<<t++<<": "<<ans<<endl; } return 0;}
0 0
- hdu 5999 The Third Cup is Free
- HDU 5999 The Third Cup is Free
- HDU - 5999 The Third Cup is Free 贪心
- HDU 5999—The Third Cup is Free
- The Third Cup is Free
- HDU5999-The Third Cup is Free
- The Third Cup is Free
- This is the third time geekband
- The third
- The Free Lunch Is Over(译)
- The Free Lunch Is Over - Bombe
- Facebook Hacker Cup 2016 Qualification Round The Price is Correct
- [hdu] CUP
- THE THIRD CENTOS INSTALLATION
- The third week
- the third 实训课
- The third day
- The third (构造方法)
- mysql表的清空、删除和修改操作详解
- Java入门 一、类和对象
- Android开发之大图片加载内存溢出
- 仿腾讯漫画目录页实现
- 453. Minimum Moves to Equal Array Elements#1(Done)
- hdu 5999 The Third Cup is Free
- 06JSP内置对象response
- SPOJ - TAP2013H D - Horace and his primes 素数筛+素数分解+打表
- HTML基础:文本的排版格式(5)
- Nunit 写法不错
- MVC之构建一个购物网站
- IOS开发入门(8)-本地化(1)
- PHPStorm设置xdebug工具调试php(使用浏览器或不使用浏览器两种方法)
- Leetcode-477. Total Hamming Distance