1. 程式人生 > >HDU 5999: The Third Cup is Free

HDU 5999: The Third Cup is Free

cout san als ++ link ref space sort int


[email protected] http://acm.hdu.edu.cn/showproblem.php?pid=5999
[email protected] Sycamore
[email protected] 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;
}

HDU 5999: The Third Cup is Free