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
题目分析:
给你N个人的队列,每个人都有想站的位置,要你从前往后的给他们排序,输出最后的结果。注意,后面的人会覆盖前面的。就是是原本在该位置上的人往后移动一个位置。
算法分析:
我们可以把总人数当作区间的大小,然后结果就是把区间的每一个位置都放上人,就是答案了。
而从题目中我们可以知道,后面的人是不受前面的人的影响的。所以,我们可以倒这来模拟过程。
如何模拟呢?我们可以想到...
分类:
其他好文 时间:
2014-08-08 12:49:05
阅读次数:
164
Buy TicketsTime Limit: 4000 MS Memory Limit: 65536 KB64-bit integer IO format: %I64d , %I64u Java class name: Main[Submit] [Status] [Discuss]Descripti...
分类:
其他好文 时间:
2014-08-08 12:13:15
阅读次数:
227
Buy TicketsTime Limit:4000MSMemory Limit:65536KTotal Submissions:12930Accepted:6412DescriptionRailway tickets were difficult to buy around the Lunar N...
分类:
其他好文 时间:
2014-08-07 12:59:20
阅读次数:
340
Ekka Dokka
Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
Submit
Status
Description
Ekka and his friend Dokka decided to buy a cake. They both love cakes and that's ...
分类:
其他好文 时间:
2014-08-07 09:52:29
阅读次数:
249
Best Time to Buy and Sell StockSay you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to compl...
分类:
其他好文 时间:
2014-08-07 00:20:37
阅读次数:
185
Best Time to Buy and Sell Stock IISay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the ...
分类:
其他好文 时间:
2014-08-07 00:20:17
阅读次数:
257
POJ 2827 Buy Tickets(排队问题,线段树应用)
ACM
题目地址:POJ 2827 Buy Tickets
题意:
排队买票时候插队。
给出一些数对,分别代表某个人的想要插入的位置Pos_i和他的Val_i,求出最后的队列的val顺序。
分析:
也是一道很巧妙的题目。
刚开始天真的以为sort一下就行了。wa了一发后发现我错了...
原...
分类:
其他好文 时间:
2014-08-06 01:55:20
阅读次数:
232
题目链接题意:有N个人排队,给出各个人想插队的位置和标识,要求输出最后的序列。分析:因为之前的序列会因为插队而变化,如果直接算时间复杂度很高,所以可以用线段树逆序插入,把序列都插到最后一层,len记录该区间里还剩余多少位置,插入的时候就插到剩余的第几个位置,比如1,2已经插入了,如果再想插入第3个位...
分类:
其他好文 时间:
2014-08-05 11:05:09
阅读次数:
227