HDU-1260.Tickets(简单线性DP)】的更多相关文章

传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1260 Tickets Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7318    Accepted Submission(s): 3719 Problem Description Jesus, what a great movie! Th…
本题大意:排队排票,每个人只能自己单独购买或者和后面的人一起购买,给出k个人单独购买和合买所花费的时间,让你计算出k个人总共花费的时间,然后再稍作处理就可得到答案,具体格式看题意. 本题思路:简单dp,用dp[ i ]来存储前i个人购买票所需要的最小时间,则很容易得出状态转移方程为dp[ i ] = min (dp[i - 1] + a[ i ], dp[i - 2] + b[i - 1]); 参考代码: #include <iostream> #include <cstring>…
一开始我对这个题的题意理解有问题,居然超时了,我以为是区间dp,没想到是个水dp,我泪奔了.... #include<stdio.h> #include<string.h> #include<algorithm> #include<cmath> #include<iostream> using namespace std; ///本来以为是一个区间dp,结果是个水dp,从前往后选就可以了,选的方式有两种,每次都是最优,结果也最优; ///我还TL…
2046 : 生化危机 时间限制:1 Sec内存限制:128 MiB提交:19答案正确:8 题目描述 当致命的T病毒从Umbrella Corporation 逃出的时候,地球上大部分的人都死去了. 麻烦的是,他们并没有真正的死去. 爱丽诗在一个狭窄的巷子中,遇见了n个丧尸(编号1-n),巷子太窄了,爱丽诗只能按顺序解决它们. 爱丽诗擅长用匕首和弓箭,当爱丽诗面临编号为i的丧尸时,匕首每次只能解决一个丧尸用时为a[i],弓箭每次能且只能解决两个相邻的丧尸(丧尸i,和丧尸i+1),用时为b[i].…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1260 Problem Description Jesus, what a great movie! Thousands of people are 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…
Lucky tickets Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3298 Accepted: 2174 Description The public transport administration of Ekaterinburg is anxious about the fact that passengers don't like to pay for passage doing their best to a…
Tickets Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 711    Accepted Submission(s): 354 Problem Description Jesus, what a great movie! Thousands of people are rushing to the cinema. However,…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1260 题意 有N个人来买电影票 因为售票机的限制 可以同时 卖一张票 也可以同时卖两张 卖两张的话 两个人必须是相邻的 给出 N 个 价格 是 一个一个买的时间花费 给出 N - 1个价格 是 相邻的两个人一起买的时间花费 求出 最小的时间花费 思路 dp[i] 表示 卖到当前这个人的时间花费 状态转移方程 dp[i] = min(dp[i - 2] + b[i - 1], dp[i - 1] +…
http://acm.hdu.edu.cn/showproblem.php?pid=1260 用dp[i]表示处理到第i个的时候用时最短. 那么每一个新的i,有两个选择,第一个就是自己不和前面的组队,第二就是和前面的组队. 那么dp[i] = min(dp[i - 1] + a[i], dp[i - 2] + b[i]);  前者是自己组队. 边界条件 dp[0] = 0; dp[1] = a[1]; #include <cstdio> #include <cstdlib> #in…
Tickets Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 972    Accepted Submission(s): 495 Problem Description Jesus, what a great movie! Thousands of people are rushing to the cinema. However,…