hdu1260(dp)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1260

分析:简单dp,dp[i]=min(dp[i-1]+a[i],dp[i-2]);

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#define LL long long
#define mod 1000000007
#define inf 1<<30
#define N 2010
using namespace std;
int a[N],dp[N];
int c[N];
int main()
{
int t,n;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=;i<=n;i++)scanf("%d",&a[i]);
for(int i=;i<=n;i++)scanf("%d",&c[i]);
memset(dp,,sizeof(dp));
dp[]=a[];
for(int i=;i<=n;i++)dp[i]=min(dp[i-]+c[i],dp[i-]+a[i]);
int sum=dp[n];
int h=sum/+;
int m=(sum%)/;
int s=sum%;
printf("%02d:%02d:%02d",h,m,s);
if(h>=)printf(" pm\n");
else printf(" am\n");
} }
上一篇:wuzhicms访问统计实现方法


下一篇:eclipse maven 编译打包环境配置