#include<cstdio>
#include<cstring>
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)>(y)?(x):(y))
long long int dp[10000];
int d[10000];
int step[10000];
int main()
{
int T;
scanf("%d",&T);
int n,t,m;
while(T--)
{
scanf("%d%d%d",&n,&t,&m);
for(int i=1;i<=m;i++)
scanf("%d",&d[i]);
for(int i=0;i<=m;i++)
dp[i]=1000000;
memset(step,0x3f,sizeof(step));
dp[0]=0;
step[0]=0;
for(int i=1;i<=m;i++)
{
for(int j=0;j<i;j++)
{
int tem=MAX(d[i],dp[j])+(i-j+n-1)/n*t*2;
if(dp[i]>=tem)
{
dp[i]=tem;
step[i]=MIN(step[i],step[j]+(i-j+n-1)/n);
}
}
}
printf("%lld %d\n",dp[m]-t,step[m]);
}
}
poj 2336 DP
最新推荐文章于 2021-03-20 14:37:00 发布