可耻的看了题解 巧妙的思维 逆序插入,pos 代表的意义为前面要有pos个空格才OK: 证明:仔细思考一下就觉得是正确的,但是要想到这种方式还是要很聪明,空格是前面的几个数字所形成的,所以要特地留出来,因为这几个空格是既定的事实 线段树实现 线段的意义:当前线段留的空格数,满足区间和性质 代码如下: #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #includ…
[POJ2828] Buy Tickets(待续) 题目大意:多组测试,每组给出\(n\)条信息\((a,b)\),表示\(b\)前面有\(a\)个人,顺序靠后的信息优先级高 Solution.1 由后向前看,每个遇到的都是确定位置的,最后的人选定的位置不会改变,同样因为是倒叙输入,在第\(i\)个人后插队,也就是说他的前面一定要留下\(i\)个空格. 形象一点就是这样: 从后往前,去查找第一个大于所需要空白的位置.用线段树维护空格数目即可 Code.1 #include <iostream>…
飞翔 问题是这样的:现在有n个人要买票,但是天黑可以随便插队.依次给出将要买票的n个人的数据信息.包含两项:pos,当前第i号人来了之后他肯定要插入到pos这个位置,如果当前pos无人,那最好了,直接把他插入即可.但如果pos这个位置有人了,从现实意义上讲,第i号人插入之后,相当于他 后面的人在原来的基础上都往后挪了一个位置!(ps:这就是为什么人们都讨厌插队的人的原因啊!!!) 每一个人都携带一个val值,当n个人全部确定下 来之后输出val序列.   分析:可以这样想,就算是你先到的,先排到…
Buy Tickets Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 22097   Accepted: 10834 Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue… The Lunar New Year w…
题目地址:POJ 2828 Buy Tickets Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue… The Lunar New Year was approaching, but unluckily the Little Cat still had schedules going…
线段树 Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue- The Lunar New Year was approaching, but unluckily the Little Cat still had schedules going here and there. Now, h…
Buy Tickets Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 12296   Accepted: 6071 Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue- The Lunar New Year wa…
/* Buy Tickets Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 10207 Accepted: 4919 Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue… The Lunar New Year was…
Buy Tickets Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 12930   Accepted: 6412 Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue… The Lunar New Year wa…
题目传送门 Buy Tickets Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 22611   Accepted: 11045 Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue… The Lunar New…