HDU Tickets(简单的dp递推)
Tickets
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 972 Accepted Submission(s): 495
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.
2
20 25
40
1
8
08:00:08 am
#include<iostream>
using namespace std;
int a[],b[],dp[];
#define min(x,y) (x)<(y)? (x):(y)
int n;
void pre()
{
int i,j;
cin>>n;
for(i=;i<=n;i++) cin>>a[i];
for(i=;i<=n;i++) cin>>b[i];
}
void solve()
{
int i,j;
dp[]=;dp[]=a[];
for(i=;i<=n;i++)
dp[i]=min(dp[i-]+a[i],dp[i-]+b[i]);
int num=dp[n];
int h,m,s;
h=num//;num-=h**;
m=num/;num-=m*;
s=num;
printf("%02d:%02d:%02d",h+>? h+-:h+,m,s);
printf(" %s\n",h+>? "pm":"am");
}
int main(void)
{
int t,i,j;
while(cin>>t){
while(t--){
pre();
solve();
}
}
return ;
}
HDU Tickets(简单的dp递推)的更多相关文章
- HDU 6076 Security Check DP递推优化
Security Check Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others) ...
- hdu2089(数位DP 递推形式)
不要62 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- 题解报告:hdu 2084 数塔(递推dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2084 Problem Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这 ...
- hdu 1284 钱币兑换问题 (递推 || DP || 母函数)
钱币兑换问题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- hdu 2604 Queuing(dp递推)
昨晚搞的第二道矩阵快速幂,一开始我还想直接套个矩阵上去(原谅哥模板题做多了),后来看清楚题意后觉得有点像之前做的数位dp的水题,于是就用数位dp的方法去分析,推了好一会总算推出它的递推关系式了(还是菜 ...
- hdu 1723 DP/递推
题意:有一队人(人数 ≥ 1),开头一个人要将消息传到末尾一个人那里,规定每次最多可以向后传n个人,问共有多少种传达方式. 这道题我刚拿到手没有想过 DP ,我觉得这样传消息其实很像 Fibonacc ...
- HDU 2154 跳舞毯 | DP | 递推 | 规律
Description 由于长期缺乏运动,小黑发现自己的身材臃肿了许多,于是他想健身,更准确地说是减肥. 小黑买来一块圆形的毯子,把它们分成三等分,分别标上A,B,C,称之为“跳舞毯”,他的运动方式是 ...
- HDU 5366 dp 递推
The mook jong Accepts: 506 Submissions: 1281 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65 ...
- HDU 3469 Catching the Thief (博弈 + DP递推)
Catching the Thief Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
随机推荐
- Android扫描SD卡中的文件
当android的系统启动的时候,系统会自动扫描sdcard内的多媒体文件,并把获得的信息保存在一个系统数据库中,以后在其他程序中如果想要访问多媒体文件的信息,其实就是在这个数据库中进行的,而不是直接 ...
- Adobe Acrobat XI Pro 官方下载及安装破解
Adobe公司推出的PDF 格式是一种全新的电子文档格式.借助 Acrobat ,您几乎可以用便携式文档格式 (Portable Document Format ,简称 PDF) 出版所有的文档. P ...
- [Leetcode][Python]25: Reverse Nodes in k-Group
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 25: Reverse Nodes in k-Grouphttps://oj. ...
- LA 5966 Blade and Sword (双向bfs + 想法) - from lanshui_Yang
题目大意:给你一张有n * m个网格的图,每个网格可能是如下符号: “#”:墙 “P”:出发点 “D”:终点 “.”:空地 “*”:传送机 有一个旅行家(假设名叫Mike),他要从点P到达点D,途中必 ...
- Codeforces Round #262 (Div. 2) B
题目: B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes inp ...
- js简繁转换,两种实现方式,妥妥的~
不知道繁简按钮有什么卵用,大陆人自带繁简转换开关的好么,但是还是项目要求,做了这么一个功能,现在整理给大家用~完美兼容~么么哒 按钮的样式可以随便用css定义,注意id不要变,注意jq的事件绑定好就o ...
- SET ANSI_NULLS (Transact-SQL)
指定在 SQL Server 2014 中与 Null 值一起使用等于 (=) 和不等于 (<>) 比较运算符时采用符合 ISO 标准的行为. 当 SET ANSI_NULLS 为 ON ...
- SQLSERVER 列名无效
很多时候对数据库表修改字段后会出现“列名无效”,或者在查询分析器里面是红色的下划线,造成这个现象的原因是:SQL Server的intellisense(智能感知功能),没有感知到更改,需要重新整理一 ...
- grunt打包过程中的注意点
1.安装nodeJS nodeJS下载地址: http://www.nodejs.org/download/ 2. 在Node.js command prompt 这个控制面板输入 npm i ...
- 安卓自定义view_GDI绘图 _2d绘图_canvas绘图
2014年到2016年 发生了很多事情,如今已成定局,现在想忘掉这些烦恼的事情,找点以前想干没有干的事情来做,塞满大脑就不去想了. 之前,一直想做一款挂机类游戏,各种平台和开发语言都选择过了,从htm ...