H. Tickets

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.

 

Input

There 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.

 

Output

For 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 DP方程:dp[i] = min(dp[i-1]+ss[i], dp[i-2]+dd[i-1])
#include <cstdio>
#include <iostream>
#include<cstring>
using namespace std;
int main()
{
int n,t,i,j;
int a[],b[],dp[];
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=;i<=n;i++)
scanf("%d",&a[i]);
for(j=;j<=n;j++)
scanf("%d",&b[j]);
dp[]=a[];
for(i=;i<=n;i++)
dp[i]=min(dp[i-]+a[i],dp[i-]+b[i]);
int hh = dp[n]/;
int mm = dp[n]%/;
int ss = dp[n]%;
printf("%02d:%02d:%02d %s\n", (+hh)%, mm, ss, (hh+)%>? "pm": "am");
}
return ;
}

最新文章

  1. git之四
  2. asp rs开启关闭问题
  3. ASP.NET空网页生成默认代码注释
  4. Atitit 知识图谱解决方案:提供完整知识体系架构的搜索与知识结果overview
  5. 2014 UESTC暑前集训数据结构专题解题报告
  6. DevExpress之ASPxGridView笔记(1)
  7. ImageButton 在IE 10 下的异常
  8. InvalidIndexNameException[Invalid index name [2Shard], must be lowercase]
  9. JavaScript 鸭子模型
  10. linux df和du统计的空间不一致
  11. 概述java语言
  12. BZOJ 4569: [Scoi2016]萌萌哒 [并查集 倍增]
  13. 恢复linux系统文件夹颜色
  14. SpringBoot Tomcat启动报错
  15. 实现img图片不能被拖动的两种简单方法
  16. 关于MySQL数据库——增删改查语句集锦
  17. JMeter实现唯一参数生成不重复时间戳
  18. kod 编辑器下载
  19. Jmeter各参数含义
  20. centos 6.5 ftp服务配置及客户端使用

热门文章

  1. PHP批量清空删除指定文件夹内容
  2. Android滑动菜单特效实现,仿人人客户端侧滑效果,史上最简单的侧滑实现
  3. cookie中文乱码
  4. EXCEL科学计数法转为文本格式
  5. python 多个 %s 例子
  6. 自定义el函数
  7. mplayer-1.3.0-2016-09-01.7z
  8. 使用原生ajax处理json组成的数组
  9. Swift - 界面的跳转模式
  10. C++ 基础知识复习(二)