博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
杭电oj--Tickets(dp)
阅读量:6957 次
发布时间:2019-06-27

本文共 1945 字,大约阅读时间需要 6 分钟。

Tickets

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 1941    Accepted Submission(s): 938

Problem Description
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
 

 

Source
 

 

Recommend
JGShining   |   We have carefully selected several similar problems for you:            
感觉dp真强大, dp[i]=min(dp[i-1]+num1[i] , dp[i-2]+num2[i-1]). 通过循环来比较求的最优解。 dp[i-1]+num1[i]每次+一个未买票的人所耗时间, dp[i-2]+num2[i-1]为两人共同买票(两次)所用时间。 求最小值。
-------- 正午据说是pm , 说法存在争议。 
1 #include 
2 #include
3 #include
4 #define min(a, b) a

 

转载于:https://www.cnblogs.com/soTired/p/4737650.html

你可能感兴趣的文章
正则表达式
查看>>
关于直播视频格式和浏览器兼容性历史的来龙去脉
查看>>
是的,InfoQ正在招聘技术编辑!跟对的人,一起做喜欢的事!
查看>>
vue2+vue-cli,dis文件加载出错解决方案
查看>>
立下“去O”Flag的AWS,悄悄修炼了哪些内功?
查看>>
关于团队建设,穆帅能教我们什么?
查看>>
2019 SRE 调查报告:事故处理是主要工作,SRE 压力山大
查看>>
xpath学习
查看>>
Java工程师的成长路线图是什么?
查看>>
JavaOne 2016——首日亮点
查看>>
EDU_BOOK 开发总结
查看>>
简单的支持网页画框拖拽缩放功能的js插件
查看>>
使用 ES2015 开发 Angular1.x 应用指南
查看>>
密码学协议 门限
查看>>
true or false in JavaScript
查看>>
Android学习笔记6:使用Intent1
查看>>
js实现继承的几种方式
查看>>
[LintCode/LeetCode] Two Strings are Anagrams/Valid Anagram
查看>>
Consul入门03 - 注册服务
查看>>
[Centos]necessary tools for newbie
查看>>