Jesus, what a great movie! Thousands of people are rushing to the cinema. However, this is really a tuff time for Joe who sells the film tickets. He is wandering when could he go back home as early as possible. 
A good approach, reducing the total time of tickets selling, is let adjacent people buy tickets together. As the restriction of the Ticket Seller Machine, Joe can sell a single ticket or two adjacent tickets at a time. 
Since you are the great JESUS, you know exactly how much time needed for every person to buy a single ticket or two tickets for him/her. Could you so kind to tell poor Joe at what time could he go back home as early as possible? If so, I guess Joe would full of appreciation for your help. 

InputThere are N(1<=N<=10) different scenarios, each scenario consists of 3 lines: 
1) An integer K(1<=K<=2000) representing the total number of people; 
2) K integer numbers(0s<=Si<=25s) representing the time consumed to buy a ticket for each person; 
3) (K-1) integer numbers(0s<=Di<=50s) representing the time needed for two adjacent people to buy two tickets together. 
OutputFor every scenario, please tell Joe at what time could he go back home as early as possible. Every day Joe started his work at 08:00:00 am. The format of time is HH:MM:SS am|pm. 
Sample Input

2
2
20 25
40
1
8

Sample Output

08:00:40 am
08:00:08 am 这个递推公式比较简单
#include <bits/stdc++.h>
#define M 2009
using namespace std; int n,k,a[M],t[M],dp[M];
int hh,mm,ss; int main()
{
scanf("%d",&n);
while(n--)
{
scanf("%d",&k);
for(int i = 1; i <= k; i++)
scanf("%d",&a[i]);
for(int i = 2; i <= k; i++)
scanf("%d",&t[i]);
dp[1] = a[1];
for(int i = 2; i <= k; i++)
dp[i] = min(dp[i-1]+a[i],dp[i-2]+t[i]); hh = dp[k]/3600;
mm = (dp[k]%3600)/60;
ss = dp[k]%60; printf("%02d:%02d:%02d %s",( 8 + hh)%24,mm,ss,(8 + hh)%24 > 12 ? "pm\n" : "am\n");
} return 0;
}

HDU 1260的更多相关文章

  1. 【DP】HDU 1260

    HDU 1260 Tickets 题意:有N个人要买票,你可以一个一个人卖票,时间分别为Xs,也可以相邻两个人一起卖票,时间为Ys,从早上八点开始卖票,问你何时最早将N个人的票卖完. 思路:解决情况是 ...

  2. 怒刷DP之 HDU 1260

    Tickets Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Stat ...

  3. 【万能的搜索,用广搜来解决DP问题】ZZNU -2046 : 生化危机 / HDU 1260:Tickets

    2046 : 生化危机 时间限制:1 Sec内存限制:128 MiB提交:19答案正确:8 题目描述 当致命的T病毒从Umbrella Corporation 逃出的时候,地球上大部分的人都死去了. ...

  4. Tickets HDU - 1260 水DP

    HDU - 1260 现在有n个人要买电影票,如果知道每个人单独买票花费的时间, 还有和前一个人一起买花费的时间,问最少花多长时间可以全部买完票. 直接dp就行,注意下输出和初始化 每次从dp[i-1 ...

  5. hdu 1260 Tickets

    http://acm.hdu.edu.cn/showproblem.php?pid=1260 题目大意:n个人买票,每个人买票都花费时间,相邻的两个人可以一起买票以节约时间: 所以一个人可以自己买票也 ...

  6. (dp)Tickets --HDU --1260

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=1260 http://acm.hust.edu.cn/vjudge/contest/view.action ...

  7. HDU 1260 Tickets (普通dp)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1260 Tickets Time Limit: 2000/1000 MS (Java/Others)   ...

  8. HDU - 1260 Tickets 【DP】

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1260 题意 有N个人来买电影票 因为售票机的限制 可以同时 卖一张票 也可以同时卖两张 卖两张的话 两 ...

  9. HDU 1260 Tickets DP

    http://acm.hdu.edu.cn/showproblem.php?pid=1260 用dp[i]表示处理到第i个的时候用时最短. 那么每一个新的i,有两个选择,第一个就是自己不和前面的组队, ...

  10. 题解报告:hdu 1260 Tickets

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1260 Problem Description Jesus, what a great movie! T ...

随机推荐

  1. 一个tomcat服务器上部署多个Web项目,不同域名访问

    [参考]一个tomcat服务器上部署多个项目,不同域名访问 我们一个服务器只按装了一个tomcat服务器,现在有多个项目或者多个域名访问,下面来进行配置 在这里我们只需要修改conf下的server. ...

  2. 寄存器理解 及 X86汇编入门

    本文整理自多材料源,感谢原址分享,请查看末尾Url I, 汇编语言分类: 汇编语言和CPU息息相关,但是不能把汇编语言完全等同于CPU的机器指令.不同架构的CPU指令并不相同,如x86,powerpc ...

  3. CentOS上安装配置Ruby on Rails

    0.install sublime editor(optional) ref:http://www.tecmint.com/install-sublime-text-editor-in-linux/ ...

  4. Python学习笔记(二)

    标识符和关键字 1,邮箱的Python标识符是任意长度的非空字符序列(引导字符+后续字符.) python标识符必须符合两条规则--标识符区分大小写 (1)只要是unicode编码字母都可以充当引导字 ...

  5. 让mysql 支持 emoji 表情

    1.数据库配置 [client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] ch ...

  6. docker参数注解

    # docker --help Usage: docker [OPTIONS] COMMAND [arg...] docker daemon [ --help | ... ] docker [ -h ...

  7. 深度学习入门之Mnist

    参看Deep learning from scratch,学习到反向传播网络后,把网络调通了,但是训练后损失函数减小,准确率没有变化,和瞎猜一样,是为什么呢?只有在看看各层缺少什么,关键是我的参数和书 ...

  8. 10.30 rest_framework总结

    2018-10-30 20:25:23 终于学完了rest_framework  这个框架! 这个框架有一些基本组件!最重要的就是看源码!要一个类一个类的去找!按顺序! 并且要自己配置类的时候要先看源 ...

  9. 【2】static 、construct

    [面向对象] 两个概念: 什么是类 具有一批相同属性的集合 什么是对象 特指的某一个具体的事物 [面向对象的三大特征] 1.封装 public 公共的 protected 受保护的 private 私 ...

  10. 验证IP地址的有效性

    实力说明 IP地址是网络上每台计算机的标识,在浏览器中输入的网址也是要经过DNS服务器转换为IP地址才能找到服务器. 关键技术 正则表达式