题目:
http://acm.hdu.edu.cn/showproblem.php?pid=4505
代码:
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=20;
int a[maxn];
int open(int i)
{
return i>0?1:0;
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int N;
scanf("%d",&N);
int i;
for(i=0;i<N;i++)
{
scanf("%d",&a[i]);
}
sort(a,a+N);
int time=0;
int temp=0;
for(i=0;i<N;i++)
{
time+=(a[i]-temp)*6+open(a[i]-temp)*5+1;
temp=a[i];
}
time+=a[N-1]*4;
printf("%d\n",time);
}
return 0;
}