码迷,mamicode.com
首页 >  
搜索关键字:cigarette coup buy cheap luck    ( 1603个结果
poj 2828 Buy Tickets
http://poj.org/problem?id=2828   题意:...
分类:其他好文   时间:2014-08-12 13:36:04    阅读次数:169
HDU 2126 Buy the souvenirs
题意:给出n纪念品的价格和钱数m,问最多能买多少件纪念品和买这些数量的纪念品的方案数。首先,求能买最多的纪念品的数量,用贪心法可以解决。将价钱排序,然后从最便宜的开始买,这样就很容易求得最多买的纪念品的数量。方案数就要用到动态规划。dp[j][k]表示花费不超过j元买k件物品的方案数dp[j][k]...
分类:其他好文   时间:2014-08-12 09:00:03    阅读次数:160
POJ训练计划2828_Buy Tickets(线段树/单点更新)
解题报告 题意: 插队完的顺序。 思路: 倒着处理数据,第i个人占据第j=pos[i]+1个的空位。 线段树维护区间空位信息。 #include #include #include using namespace std; struct node { int x,v; } num[201000]; int sum[1000000],ans[201000]; void c...
分类:其他好文   时间:2014-08-11 21:34:33    阅读次数:378
LeetCode总结 -- 一维动态规划篇
这篇文章的主题是动态规划, 主要介绍LeetCode中一维动态规划的题目, 列表如下: Climbing StairsDecode WaysUnique Binary Search TreesMaximum SubarrayBest Time to Buy and Sell Stock在介绍上述具体题目之前, 我们先说说动态规划的通常思路。 动态规划是一种算法思路(注意这里不要和递归混淆, 事实上...
分类:其他好文   时间:2014-08-10 13:03:50    阅读次数:180
算法练习 - Buy Low, Buy Lower - USACO
这道题目本身很简单,倒推回去,第K个是最优时,K+1时必然包含它.所以就从最后面的股票开始贪心法用最优解生成最优解. 难点1是去重,我直接用了个价格表去过滤,如果多个价格相等的同级最优解,就用他们中可能性最大的那个累加,其余的忽略. 难点2是大数计算.可能性可能有几十位的数字,所以封装了一个大数类.现在还不支持符号,只支持正数.后面需要用到负数的时候再说. 题目: Buy Lo...
分类:其他好文   时间:2014-08-10 12:59:00    阅读次数:436
POJ 2828 poj 2828 Buy Tickets 【树状数组,已知前n项和为K,返回n值】
题目链接:http://poj.org/problem?id=2828 在一个队列中,一个人想要插队,告诉你每个新来的人会插在i个人后面,求出最后的队列。 如果我们用模拟的话,那么时间复杂度肯定是超了;想想,如果我们逆序,那么最后来的人的位置一定是固定的,这样的话,我们将问题转化成逆序扫描给出数据,插在i个人后面这个数据就变成了在这个人前面需要留出多少个空位。如此我们只需要用树状数组记录前n项...
分类:其他好文   时间:2014-08-10 10:29:30    阅读次数:383
POJ 2828 Buy Tickets (线段树)
Buy TicketsTime Limit:4000MSMemory Limit:65536KTotal Submissions:13017Accepted:6449DescriptionRailway tickets were difficult to buy around the Lunar N...
分类:其他好文   时间:2014-08-09 15:36:48    阅读次数:308
LeetCode "Best Time to Buy and Sell Stock II"
No limit to transaction count, so it is a recursive sum calculation. Take care of boundary condition.class Solution {public: int maxProfit(vector &...
分类:其他好文   时间:2014-08-08 15:58:06    阅读次数:212
LeetCode\EPI "Best Time to Buy and Sell Stock"
Also the very first problem on EPI.class Solution {public: int maxProfit(vector &prices) { size_t len = prices.size(); if (len = pric...
分类:其他好文   时间:2014-08-08 15:53:26    阅读次数:170
Halle berries are allowed meant cheap ghd nz sale
Halle berries are allowed meant cheap ghd nz sale for later today through the day If we take a situation the load. Clothing trendy conception is also ...
分类:其他好文   时间:2014-08-08 15:41:06    阅读次数:250
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!