HDU1260DP
Tickets
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3780 Accepted Submission(s): 1896
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.
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.
题意:
处理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的更多相关文章
随机推荐
- CentOS6 安装VNCserver
1.下载vncserver yum install tigervnc tigervnc-server -y 2.配置 vncserver vi /etc/sysconfig/vncserver 在文件 ...
- JDK中的泛型
Java中的泛型介绍: 起因: 1. JDK 1.4 以前类型不明确: ① 装入集合的对象被当作 Object 类型对待,从而失去了自己的原有类型: ② 从集合中取出时往往需要转型,效率低下,并且容易 ...
- OSG学习:基本几何体绘制示例
绘制并渲染几何体主要有如下3大步骤: 1.创建各种向量数据,如顶点.纹理坐标.颜色和法线等.需要注意的是,添加顶点数据时主要按照逆时针顺序添加, 以确保背面剔除的正确. 2.实例化一个几何体对象(os ...
- 3dContactPointAnnotationTool开发日志(十七)
今天又改进了一下算法,把生成出来的接触点按中心坐标拍了个序,再把中心坐标一样的坐标点合并,x,y,z每个维度都只保留大的值.然后来看看效果: 先是1倍的,只剩下4096个接触点了,2^12个, ...
- [Redis]在.NET平台下的具体应用
一.安装第三方驱动 PM> Install-Package ServiceStack.Redis 二.使用C#语言调用类库访问Redis
- 在intelllij中debug的时候使用log4j输出
一般在本地调试的时候,在控制台打印输出都会使用system.out.print,但是在线上运行的时候一般都是使用log4j进行日志输出. 那么在编写代码的时候,又不想写两份,直接写LOG是常规动作. ...
- codeforces 730 j.bottles
J. Bottles time limit per test 2 seconds memory limit per test 512 megabytes input standard input ou ...
- Apple - Hdu5160
Problem Description We are going to distribute apples to n children. Every child has his/her desired ...
- html的body内标签之图片及表格
<li> list 标签定义和用法: <li> 标签定义列表项目. <li> 标签可用在有序列表 (<ol>) 和无序列表 (<ul>) 中 ...
- Codeforces Round #469 (Div. 2) E. Data Center Maintenance
tarjan 题意: 有n个数据维护中心,每个在h小时中需要1个小时维护,有m个雇主,他们的中心分别为c1,c2,要求这两个数据中心不能同时维护. 现在要挑出一个数据中心的子集,把他们的维护时间都推后 ...