HDU 5999: The Third Cup is Free

///@link http://acm.hdu.edu.cn/showproblem.php?pid=5999///@author Sycamore///@date Aug, 16#include<bits/stdc++.h>using namespace std;int main(){   ios::sync_with_stdio(false);   cin.tie(0);    int T;   cin>>T;   for(int t=1;t<=T;t++)   {      int n;      cin>>n;      vector<unsigned short>p(n);      for(auto &e:p)cin>>e;      sort(p.begin(),p.end());      int ans=0;      for(int i=n-1;i>=0;i-=3)         ans+=p[i];      for(int i=n-2;i>=0;i-=3)         ans+=p[i];      cout<<"Case #"<<t<<": "<<ans<<‘\n‘;   }    return 0;}
时间: 2024-12-12 06:27:22

HDU 5999: The Third Cup is Free的相关文章

HDU 1704 Rank

Rank Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 170464-bit integer IO format: %I64d      Java class name: Main there are N ACMers in HDU team.ZJPCPC Sunny Cup 2007 is coming, and lcy want to select some

HDU 1704 Rank【传递闭包】

解题思路:给出n个选手,m场比赛,问不能判断胜负的询问最多有多少种 用传递闭包即可 但是如果直接用3重循环会超时 在判断d[i][j]=d[i][k]||d[k][j]是否连通的时候 可以加一个if语句判断一下d[i][k]是否为1,为1再进行第三重循环,不为1则不进行第三次循环 反思:例如询问 3和1,1和3是相同的情况,所以最后判断的时候,只需要判断上三角矩阵即可. Rank Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32

HDU 2289 Cup(二分可以,但是除了二分呢?)

这道题目,算数学题吗?算二分题吗?充其量算个水题吧... 首先,没有用二分,但是发现了一种新的解法来代替二分. 若果按照i从0,每次增加0.00000001来一直枚举到h的话,绝逼超时.枚举量太大了 但是可以分成两步来呀: #include<cstdio> #include<cmath> #define pai acos(-1.0) double r1,r2,h,v; double get_v(double temp) { double rr=r1+(r2-r1)*temp/h;

HDU 2289 Cup【高精度,二分】

Cup Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8942    Accepted Submission(s): 2744 Problem Description The WHU ACM Team has a big cup, with which every member drinks water. Now, we know th

HDU 2289 Cup

Cup Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5597    Accepted Submission(s): 1787 Problem Description The WHU ACM Team has a big cup, with which every member drinks water. Now, we know th

Cup HDU 2289

The WHU ACM Team has a big cup, with which every member drinks water. Now, we know the volume of the water in the cup, can you tell us it height? The radius of the cup's top and bottom circle is known, the cup's height is also known. Input The input

hdu Cup

这题是道水题,用数学方法做比较简单.因为在做二分法的专题,所以这里采用二分的方式做,很简单,但是还是要用到数学的知识,比如三角形相似,圆台的 体积公式等. #include"iostream" #include"stdio.h" #include"algorithm" #include"string.h" #include"cmath" #define inf 1e-9 using namespace st

HDU 2289 Cup【二分】

<题目链接> 题目大意: 一个圆台型的杯子,它的上底半径和下底半径已经给出,并且给出它的高度,问你,体积为V的水倒入这个杯子中,高度为多少. 解题分析: 就是简单的二分答案,二分枚举杯中水的高度,然后根据几何计算出该高度下,水的上半径,然后计算出该高度下水的体积,在与实际水的体积进行比较,从而确定最终的答案. 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 5 const doubl

Bone Collector II(HDU 2639 DP)

Bone Collector II Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3471    Accepted Submission(s): 1792 Problem Description The title of this problem is familiar,isn't it?yeah,if you had took par