Tickets

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

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
 

题意:

处理k件事依次排列,每有一个件事单独处理时间,又知道相邻的两件事同时处理的时间,问这k件事最少的处理时间

代码:

//每件事考虑单独处理和他与前一个同时处理两种情况,dp求最小即可。
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int f[][],n,k,a[],b[];
int main()
{
scanf("%d",&n);
while(n--){
scanf("%d",&k);
for(int i=;i<=k;i++) scanf("%d",&a[i]);
for(int i=;i<=k;i++) scanf("%d",&b[i]);
f[][]=a[];f[][]=a[];
for(int i=;i<=k;i++){
f[][i]=min(f[][i-]+a[i],f[][i-]+a[i]);
f[][i]=f[][i-]-a[i-]+b[i];
}
int sum=min(f[][k],f[][k]);
int se=sum%;
int mi=(sum/)%;
int ho=((sum/)/)%+;
int x1,x2,x3,x4,x5,x6,flag=;
if(ho>) {ho-=;flag=;};
x1=ho/;x2=ho%;x3=mi/;x4=mi%;x5=se/;x6=se%;
printf("%d%d:%d%d:%d%d ",x1,x2,x3,x4,x5,x6);
if(flag) printf("pm\n");
else printf("am\n");
}
return ;
}

HDU1260DP的更多相关文章

随机推荐

  1. win7下本地运行spark以及spark.sql.warehouse.dir设置

    SparkSession spark = SparkSession .builder() .master("local[*]") .enableHiveSupport() .con ...

  2. 查找当前对象中的方法对象的属性叫做_event_name的方法

    setattr( self, '_events', {e._event_name: e for _, e in getmembers(self, lambda x: ismethod(x) and h ...

  3. [c++] Getting Started - CMake

    CMake is an open-source cross platform build system, according to CMake's creator, Kitware. But CMak ...

  4. BZOJ 4361 isn 容斥+dp+树状数组

    题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=4361 题意概述: 给出一个长度为N的序列A(A1,A2...AN).如果序列A不是非降的 ...

  5. 百度编辑器ueditor的图片地址修正

    我用的百度编辑器为1.4.2的,相对于现在这个时间来说是比较新的.之前去的1.3版的,后来更新到1.4之后出现路径问题.因为今天晚上出现特别奇怪的问题,所以特地又整了一遍,发现这玩意还是得自己弄通了好 ...

  6. 常用算法Java实现之选择排序

    选择排序算法在每一步中选取最小值来重新排序,通过选择和交换来实现排序. 具体流程如下: 1.首先从原数组中选择最小的1个数据,将其置于第一个位置. 2.然后从剩下的数据中再选择其中最小的一个数据,并将 ...

  7. 语音信号处理之动态时间规整(DTW)(转)

    这学期有<语音信号处理>这门课,快考试了,所以也要了解了解相关的知识点.呵呵,平时没怎么听课,现在只能抱佛脚了.顺便也总结总结,好让自己的知识架构清晰点,也和大家分享下.下面总结的是第一个 ...

  8. PHP获取网页内容的几种方法

    方法1: 用file_get_contents以get方式获取内容 <?php $url='http://www.domain.com/?para=123'; $html= file_get_c ...

  9. open-stf 安装篇(linux)

       OpenSTF 百度MTC的远程真机调试 Testin的云真机 腾讯WeTest的云真机 阿里MQC的远程真机租用 什么是OpenSTF? OpenSTF是一个手机设备管理平台,可以对手机进行远 ...

  10. LoadRunner数据库监控指标

    SQL Server 注:以下指标取自SQL Server自身提供的性能计数器. 指标名称 指标描述 指标范围 指标单位 1.SQL Server中访问方法(Access Methods)对象包含的性 ...