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的更多相关文章
随机推荐
- pymsql报错:UnicodeEncodeError: 'latin-1' codec can't encode characters End,OK!!
UnicodeEncodeError: 'latin-1' codec can't encode characters的做法基本一致,后来发现是因为使用的是mysqldb,照着网上的方法修改配置应该可 ...
- solidity 十六进制字符串转十六进制bytes
pragma solidity ^0.4.16; contract Metadata { // 十六进制字符串转换成bytes function hexStr2bytes(string data)re ...
- Linearization of the kernel functions in SVM(多项式模拟)
Description SVM(Support Vector Machine)is an important classification tool, which has a wide range o ...
- 第二十一次ScrumMeeting会议
第二十一次Scrum Meeting 时间:2017/12/11 地点:SPR咖啡馆 人员:王子铭 游心 解小锐 王辰昱 李金奇 杨森 陈鑫 赵晓宇 照片: 目前工作进展 名字 今日 明天的工作 蔡帜 ...
- 第一章 Java Web应用开发技术
Java Web应用开发是基于JavaEE(JavaEnterprise Edition)框架的,而JavaEE是建立在Java平台上的企业级应用解决方案.JavaEES框架提供的Web开发技术主要支 ...
- unity像素贪吃蛇
[ 星 辰 · 别 礼 ] 设计过程: 首先,在之前玩坏控制台做的那个c#贪吃蛇之后,我以为做unity会很简单,但事实比较不如人意...拖了好几天.因为过程中遇到一些问题 蛇身的移动,还是用列表,将 ...
- vue-cli项目里npm安装使用elementUI
第一步:进入到项目目录里 npm i element-ui -S 第二步:在main.js中引入 import ElementUI from 'element-ui' import 'element- ...
- C#中pictureBox笔记
if (File.Exists(productInfo.预览图路径)) this.picPreview.Image = BitmapFactory.Alloc(productInfo.预览图路径, f ...
- Visual Stdio 2015打包安装项目的方法(使用Visual Studio Installer)
首先在官网下载VS2015的Visual Studio Installer 1.创建安装项目 里面最左侧的框框有三个文件夹 1.“应用程序文件夹”即"Application Folder&q ...
- [BZOJ2961] 共点圆 [cdq分治+凸包]
题面 BZOJ传送门 思路 首先考虑一个点$(x_0,y_0)$什么时候在一个圆$(x_1,y_1,\sqrt{x_1^2+y_1^2})$内 显然有:$x_1^2+y_1^2\geq (x_0-x_ ...