这题就是一个人买还是两个人买,直接选择一下,而且默认是排好了的,就是DP一下,可能不知道DP的人,也是这么写的吧。DP是一种思想啊。

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PI;
typedef pair< PI, int> PII;
const double eps=1e-5;
const double pi=acos(-1.0);
const int mod=1e9+7;
const int INF=0x3f3f3f3f; const int N=2010; int a[N];
int b[N];
int dp[N]; int main()
{
int n,time,t,i;
cin>>t;
while(t--)
{
cin>>n;
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(i=2;i<=n;i++)
scanf("%d",&b[i]);
memset(dp,0,sizeof(dp));
dp[1]=a[1];
for(i=2;i<=n;i++){
dp[i]=min(dp[i-1]+a[i],dp[i-2]+b[i]);
} char s[5];
time=dp[n];
int ss,hh,mm;
ss=time%60;
mm=(time-ss)/60%60;
hh=(time-ss-mm*60)/3600+8;
hh%=24;
if(hh>12){
strcpy(s,"pm");
}
else
strcpy(s,"am");
if(hh!=12)
hh%=12;
printf("%02d:%02d:%02d %s\n",hh,mm,ss,s);
}
return 0;
}

hdoj1260【简单DP】的更多相关文章

  1. HDU 1087 简单dp,求递增子序列使和最大

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  2. Codeforces Round #260 (Div. 1) A. Boredom (简单dp)

    题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. ...

  3. codeforces Gym 100500H A. Potion of Immortality 简单DP

    Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/a ...

  4. 简单dp --- HDU1248寒冰王座

    题目链接 这道题也是简单dp里面的一种经典类型,递推式就是dp[i] = min(dp[i-150], dp[i-200], dp[i-350]) 代码如下: #include<iostream ...

  5. poj2385 简单DP

    J - 简单dp Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65536KB     64bit ...

  6. hdu1087 简单DP

    I - 简单dp 例题扩展 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     ...

  7. poj 1157 LITTLE SHOP_简单dp

    题意:给你n种花,m个盆,花盆是有顺序的,每种花只能插一个花盘i,下一种花的只能插i<j的花盘,现在给出价值,求最大价值 简单dp #include <iostream> #incl ...

  8. hdu 2471 简单DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2571 简单dp, dp[n][m] +=(  dp[n-1][m],dp[n][m-1],d[i][k ...

  9. Codeforces 41D Pawn 简单dp

    题目链接:点击打开链接 给定n*m 的矩阵 常数k 以下一个n*m的矩阵,每一个位置由 0-9的一个整数表示 问: 从最后一行開始向上走到第一行使得路径上的和 % (k+1) == 0 每一个格子仅仅 ...

  10. poj1189 简单dp

    http://poj.org/problem?id=1189 Description 有一个三角形木板,竖直立放.上面钉着n(n+1)/2颗钉子,还有(n+1)个格子(当n=5时如图1).每颗钉子和周 ...

随机推荐

  1. webpack2 详解

    1.安装 npm install webpack -g npm install webpack -save-dev 2.编辑配置文件 // 引入 path var path=require('path ...

  2. npoi 加密 https://bbs.csdn.net/topics/380226272

    终于解决了,.1.用excel新建一个文件作为模板,可以是空内容,在excel中对文件进行加密,如密码为:12345. 2.在NPOI读取前,调用:Biff8EncryptionKey.Current ...

  3. HDU 2669 Romantic(扩展欧几里德)

    题目链接:pid=2669">http://acm.hdu.edu.cn/showproblem.php?pid=2669 Problem Description The Sky is ...

  4. c++vector简单实现

    const int DEFAULT_CAP = 3; template <typename T> class vector { // int capacity; T* _data; int ...

  5. MRUnit测试

    新建一个专门的测试类,代码如下: wordcount的map函数输入string line,      输出<单词 , 1> 右键-> run as junit 出错了,因为输出不是 ...

  6. python安装easy_install和pip

    1 安装easy_install https://pypi.python.org/pypi/setuptools 下载setuptools 执行python setup.py install就安装成功 ...

  7. bash_action

    https://stackoverflow.com/questions/12076326/how-to-install-maven2-on-redhat-linux #!/bin/bash # Tar ...

  8. 简说 call() 、apply() 、bind()

    对于这三个方法,我想一部分人还是比较陌生的. 所以今天来个简单的介绍~ 我们可以将call()和apply()看作是某个对象的方法,通过调用方法的形式来间接调用函数.call()和apply()的第一 ...

  9. poj 2228 Naptime(DP的后效性处理)

    \(Naptime\) \(solution:\) 这道题不做多讲,它和很多区间DP的套路一致,但是这一道题它不允许断环成链,会超时.但是我们发现如果这只奶牛跨夜休息那么它在不跨夜的二十四个小时里一定 ...

  10. AIM Tech Round (Div. 2) C. Graph and String

    C. Graph and String time limit per test 2 seconds memory limit per test 256 megabytes input standard ...