Tickets

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4393    Accepted Submission(s): 2236

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
题意:

知道一个人买票花的时间和和前面那个人一起买票花的时间,问最少花多少时间可以把票卖完..

输入:

    给出T,表示有T组样例

    给出n,表示有n个人买票..

    给出n个数表示这个人单独买票会花的时间..

    给出n-1个数,表示这个人和前面那个人一起买票会花的时间..

思路:dp[i]表示前i个人所用的最短时间,则转移方程为:dp[i]=min(dp[i-1]+a[i],dp[i-2]+b[i-1]);
代码:
 #include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<ctype.h>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#define ll long long
#define db double
using namespace std;
const int N=1e6+;
const int mod=1e9+;
int a[],b[];
ll dp[N];
int h,m,s;
int main(){
int n;
int k;
scanf("%d",&n);
while(n--){
scanf("%d",&k);
for(int j=;j<=k;j++) scanf("%d",a+j);
for(int j=;j<=k-;j++) scanf("%d",b+j);
memset(dp,, sizeof(dp));
dp[]=a[];
for(int i=;i<=k;i++){
dp[i]=min<ll>(dp[i-]+a[i],dp[i-]+b[i-]);
}
h=dp[k]/+,m=dp[k]%/,s=dp[k]%;
if(h>){
printf("%02d:%02d:%02d pm\n",h-,m,s);
}
else printf("%02d:%02d:%02d am\n",h,m,s);
}
}

HDOJ 1260 DP的更多相关文章

  1. hdoj 1260 Tickets【dp】

    Tickets Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

  2. poj 1260 dp

    Description In Pearlania everybody is fond of pearls. One company, called The Royal Pearl, produces ...

  3. HDOJ 1069 DP

    开启DP之路 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1069 描述一下: 就是给定N(N<=20)个方体,让你放置,求放置的最高高度,限制条件 ...

  4. hdoj 1257 DP||贪心

    最少拦截系统 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  5. Pearls POJ - 1260 dp

    题意:有n种不同的珍珠 每种珍珠的价格不同  现在给出一个采购单 标注了需要不同等级的珍珠和相对于的个数(输入按价格升序排列) 其中 价格为   (当前种类价格+10)*购买数量  这样就有一种诡异的 ...

  6. HDOJ 3944 DP?

    尽量沿着边走距离最短.化减后 C(n+1,k)+ n - k, 预处理阶乘,Lucas定理组合数取模 DP? Time Limit: 10000/3000 MS (Java/Others)    Me ...

  7. 2019的hdu暑假作业(欢迎纠错)

    1219 遍历计数. #include<bits/stdc++.h> #define QAQ 0 using namespace std; ]; ]; int main(){ )){ me ...

  8. 【DP】HDU 1260

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

  9. POJ 1260 Pearls 简单dp

    1.POJ 1260 2.链接:http://poj.org/problem?id=1260 3.总结:不太懂dp,看了题解 http://www.cnblogs.com/lyy289065406/a ...

随机推荐

  1. Python列表(一)

    列表由一系列特定顺序排列的元素组成,在python中使用[]来表示列表,并用,来进行元素分割. >>> name_list['alben', 'james', 'harden', ' ...

  2. Hibernate与Jpa的关系(1)

    [转自:http://freewind.me/blog/20111129/588.html ] 我知道Jpa是一种规范,而Hibernate是它的一种实现.除了Hibernate,还有EclipseL ...

  3. Random Forest Classification of Mushrooms

    There is a plethora of classification algorithms available to people who have a bit of coding experi ...

  4. Vulkan Tutorial 07 Window surface

    操作系统:Windows8.1 显卡:Nivida GTX965M 开发工具:Visual Studio 2017 到目前为止,我们了解到Vulkan是一个与平台特性无关联的API集合.它不能直接与窗 ...

  5. DRBD+Heartbeat+Mysql高可用读写分离架构

    声明:本案例仅为评估测试版本 注意:所有服务器之间必须做好时间同步 架构拓扑 IP信息: Heartbeat安装部署 1.安装heartbeat(主备节点同时安装) [root@master1 ~]# ...

  6. 一篇%3CDIV%20style%3D%22FONT-SIZE%

    %3CDIV%20style%3D%22FONT-SIZE%3A%2016px%22%3E1%EF%BC%8C%E6%88%91%E4%BB%A5%E4%B8%BA%E7%BB%88%E6%9C%89 ...

  7. 【webpack】webpack-dev-server生猛上手——让我们来搭一个webpack的微服务器吧!

      [前言]:因为最近在搞百度地图API的时候到了webpack的externals,才发现我之前都只是用webpack做一些搭建完项目后的"收尾工作"--即打包,而没有把它纳入到 ...

  8. CRL快速开发框架4.4版发布,支持主从读写分离

    经过一些调整和优化,4.3已经运行在生产环境,对于不久将会遇到的查询性能,读写分离需求列上日程 读写分离需求 对于一个数据库作了主从发布/订阅,主库为DB1,从库为DB2 所有写入通过DB1,所有查询 ...

  9. 限制容器对CPU的使用 - 每天5分钟玩转 Docker 容器技术(28)

    上节学习了如何限制容器对内存的使用,本节我们来看CPU. 默认设置下,所有容器可以平等地使用 host CPU 资源并且没有限制. Docker 可以通过 -c 或 --cpu-shares 设置容器 ...

  10. Spring+SpringMVC+MyBatis深入学习及搭建(十二)——SpringMVC入门程序(一)

    转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/6999743.html 前面讲到:Spring+SpringMVC+MyBatis深入学习及搭建(十一)——S ...