HDU 5999: The Third Cup is Free
阿新 • • 發佈:2017-08-17
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++)
{
intn;
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