hdoj 1260 Tickets【dp】
Tickets
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1935 Accepted Submission(s):
933
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.
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.
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.
#include<stdio.h>
#include<string.h>
#define MAX 2100
#define min(x,y)(x<y?x:y)
int a[MAX],b[MAX],dp[MAX];
int main()
{
int t,i,j,n;
int h,m,s;
int sum,tot;
scanf("%d",&t);
while(t--)
{
memset(dp,0,sizeof(dp));
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(i=2;i<=n;i++)
scanf("%d",&b[i]);
dp[1]=a[1];
for(i=2;i<=n;i++)
dp[i]=min(dp[i-1]+a[i],dp[i-2]+b[i]);
//printf("%d\n",dp[n]);
sum=dp[n];
h=0;s=0;m=0;
s=sum%60;
m=(sum-s)/60;
if(m>=60)
{
h=h+m/60;
m=m%60;
}
h=8+h;
if(h<=12)
printf("%02d:%02d:%02d am\n",h,m,s);
else
{
h-=12;
printf("%02d:%02d:%02d pm\n",h,m,s);
} }
return 0;
}
hdoj 1260 Tickets【dp】的更多相关文章
- HDU - 1260 Tickets 【DP】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1260 题意 有N个人来买电影票 因为售票机的限制 可以同时 卖一张票 也可以同时卖两张 卖两张的话 两 ...
- HDOJ 1501 Zipper 【DP】【DFS+剪枝】
HDOJ 1501 Zipper [DP][DFS+剪枝] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- HDOJ 1423 Greatest Common Increasing Subsequence 【DP】【最长公共上升子序列】
HDOJ 1423 Greatest Common Increasing Subsequence [DP][最长公共上升子序列] Time Limit: 2000/1000 MS (Java/Othe ...
- HDOJ 1257 最少拦截系统 【DP】
HDOJ 1257 最少拦截系统 [DP] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- HDOJ 1159 Common Subsequence【DP】
HDOJ 1159 Common Subsequence[DP] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- Kattis - honey【DP】
Kattis - honey[DP] 题意 有一只蜜蜂,在它的蜂房当中,蜂房是正六边形的,然后它要出去,但是它只能走N步,第N步的时候要回到起点,给出N, 求方案总数 思路 用DP 因为N == 14 ...
- HDOJ_1087_Super Jumping! Jumping! Jumping! 【DP】
HDOJ_1087_Super Jumping! Jumping! Jumping! [DP] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- POJ_2533 Longest Ordered Subsequence【DP】【最长上升子序列】
POJ_2533 Longest Ordered Subsequence[DP][最长递增子序列] Longest Ordered Subsequence Time Limit: 2000MS Mem ...
- HackerRank - common-child【DP】
HackerRank - common-child[DP] 题意 给出两串长度相等的字符串,找出他们的最长公共子序列e 思路 字符串版的LCS AC代码 #include <iostream&g ...
随机推荐
- redis【摘自网上,只为以后查看】
ubuntu安装启动redis 1.下载安装 cd /tmp wget http://redis.googlecode.com/files/redis-2.2.13.tar.gz tar -zxf r ...
- 学会怎样使用Jsp 内置标签、jstl标签库及自定义标签
学习jsp不得不学习jsp标签,一般来说,对于一个jsp开发者,可以理解为jsp页面中出现的java代码越少,对jsp的掌握就越好,而替换掉java代码的重要方式就是使用jsp标签. jsp标签的分 ...
- PC110302/UVA10010
下周开始就省选了,ACM的日子在今年内应该就会结束了,大三了,最后一次机会了,小小感伤一下-- 今天广州下大雨,心情怪怪的,感觉码不出质量高的,又很久没做过PC了,就刷刷水题吧. 老实说Program ...
- 【原创】The Error in Android developing
本文停止更新.... 鼠标渣渣 ,点一次 成两次 R.java文件不幸中枪 被拖动修改... 最后application编译运行时 解决方案:project-clean 问题解决了.. 2 ...
- Vive开发教程汇总
最近在整理在HTC Vive平台上开发VR应用程序的教程,现在把结果全部汇总在下面的表格里,希望更多的开发者参与到VR内容的开发之中,真的很好玩.现在主流的开发VR应用的引擎是Unity3D和Unre ...
- iPhone分辨率
分辨率和像素 1.iPhone5 4" 分辨率320x568,像素640x1136,@2x 2.iPhone6 4.7" 分辨率3 ...
- git 创建多个账户ssh
创建一个账户 创建ssh本地秘钥. $ ssh-keygen -t rsa -C "youremail@xxx.com" 一路回车,会在~/.ssh/目录下生成id_rsa和id_ ...
- 安装linux系统后要做的事情
基本安装0 http://www.kali.org.cn/thread-20517-1-1.html 基本安装1 http://defcon.cn/1618.html 基本安装2 http://www ...
- Windows命令行下pip安装python whl包
因为做网页爬虫,需要用到一个爬新闻的BeautifulSoup 的包,然后再关网上下的是whl包,第一次装,虽然花了点时间,最后还是装上去了,记录一下,方便下次. 先发一下官方文档地址.http:// ...
- IPv6被拒如何破?-b
APP在美国的IPv6-Only网络环境下测试不通过. 网上各种方法都试了,什么NSURLConnection, Reachability,试完还是拼人品,快要跪了 小伙伴们开始质疑这种测试方法了. ...