hdoj--1260--Tickets(简单dp)
Tickets
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2146 Accepted Submission(s): 1039
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
2
20 25
40
1
8
08:00:40 am
08:00:08 am
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define MAX 101000
int dp[MAX],man[MAX],two[MAX];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
memset(man,0,sizeof(man));
memset(two,0,sizeof(two));
for(int i=1;i<=n;i++)
scanf("%d",&man[i]);
for(int i=2;i<=n;i++)
scanf("%d",&two[i]);
memset(dp,0,sizeof(dp));
dp[1]=man[1];
for(int i=2;i<=n;i++)
dp[i]=min(dp[i-1]+man[i],dp[i-2]+two[i]);
int p=28800+dp[n];
int h=p/3600;
int m=p%3600/60;
int s=(p%3600)%60;
if(p>=43200)
{
if(h>12)
h-=12;
printf("%02d:%02d:%02d pm\n",h,m,s);
}
else
printf("%02d:%02d:%02d am\n",h,m,s);
}
return 0;
}
hdoj--1260--Tickets(简单dp)的更多相关文章
- hdoj 1260 Tickets【dp】
Tickets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
- POJ 1260 Pearls 简单dp
1.POJ 1260 2.链接:http://poj.org/problem?id=1260 3.总结:不太懂dp,看了题解 http://www.cnblogs.com/lyy289065406/a ...
- HDU - 1260 Tickets 【DP】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1260 题意 有N个人来买电影票 因为售票机的限制 可以同时 卖一张票 也可以同时卖两张 卖两张的话 两 ...
- 【万能的搜索,用广搜来解决DP问题】ZZNU -2046 : 生化危机 / HDU 1260:Tickets
2046 : 生化危机 时间限制:1 Sec内存限制:128 MiB提交:19答案正确:8 题目描述 当致命的T病毒从Umbrella Corporation 逃出的时候,地球上大部分的人都死去了. ...
- HDOJ 1501 Zipper 【简单DP】
HDOJ 1501 Zipper [简单DP] Problem Description Given three strings, you are to determine whether the th ...
- HDU 1260 Tickets (普通dp)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1260 Tickets Time Limit: 2000/1000 MS (Java/Others) ...
- HDU-1260.Tickets(简单线性DP)
本题大意:排队排票,每个人只能自己单独购买或者和后面的人一起购买,给出k个人单独购买和合买所花费的时间,让你计算出k个人总共花费的时间,然后再稍作处理就可得到答案,具体格式看题意. 本题思路:简单dp ...
- HDU 1087 简单dp,求递增子序列使和最大
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- Codeforces Round #260 (Div. 1) A. Boredom (简单dp)
题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. ...
- codeforces Gym 100500H A. Potion of Immortality 简单DP
Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/a ...
随机推荐
- win32 Service memory leak
https://stackoverflow.com/questions/2728578/how-to-get-phyiscal-path-of-windows-service-using-net ht ...
- 超高性能管线式HTTP请求(实践·原理·实现)
超高性能管线式HTTP请求(实践·原理·实现) 一.总结 一句话总结:实际pipe早就被http1.1所支持,并且大部分nginx服务器也支持并开启了这一功能. pipe之所以能比常规请求方式性能高出 ...
- 使用神经网络-垃圾邮件检测-LSTM或者CNN(一维卷积)效果都不错【代码有问题,pass】
from sklearn.feature_extraction.text import CountVectorizer import os from sklearn.naive_bayes impor ...
- [jzoj 6092] [GDOI2019模拟2019.3.30] 附耳而至 解题报告 (平面图转对偶图+最小割)
题目链接: https://jzoj.net/senior/#main/show/6092 题目: 知识点--平面图转对偶图 在求最小割的时候,我们可以把平面图转为对偶图,用最短路来求最小割,这样会比 ...
- POJ 2137 DP
思路: 枚举第一个点集中起点是哪个. 因为第i个点集总和第i-1个点集和第i+1个点集相连. 我们就可以DP求出最优解了. f[i][j]=min(f[i][j],f[i-1][k]+dis(i,j, ...
- Android Studio 插件 GsonFormat :你还在烦恼 为 Json格式 生成 JavaBean实体类吗?
在网络层,互联网提供所有应用程序都要使用的两种类型的服务,尽管目前理解这些服务的细节并不重要,但在所有TCP/IP概述中,都不能忽略他们: 无连接分组交付服务(Connectionless Packe ...
- Repeater控件使用小结持续更新
Repeater嵌套Repeater绑定数据 前台代码 <!--注意层级关系不要写错了--> <asp:Repeater ID="rpGroup" runat=& ...
- 【译文】采用chrome的DevTool中TimeLine和profile工具提升Web app性能
->译文,原文在这里<- 本文地址: http://www.cnblogs.com/blackmanba/p/web-perfomance-with-Chrome-DevTools.htm ...
- 有关PHP数组
在PHP中,数组就是关键字和值的集合,我们可以使用array关键字创建: $arr=array[100,200,300,400,500]: //这是一个自定义数组,数组里面的值是自 ...
- Android 自定义简单控件--星级评价
效果图 实现 package com.easypass.carstong.view; import android.content.Context; import android.content.re ...