poj2828 BuyTickets 线段树】的更多相关文章

Buy Tickets Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 17326   Accepted: 8601 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…
题目链接:https://vjudge.net/problem/POJ-2828 题意:有n个人,依次给出这n个人进入队列时前面有多少人p[i],和它的权值v[i],求最终队列的权值序列. 思路:基本类似于poj2182,简化题意后即为求序列1..n中第k小的值的问题.读入数据量比较大,最好读入优化.我们从n..1逆序遍历,则可以确认最后一个人的最终位置为p[n]+1,然后从序列中删除p[n]+1,继续操作倒数第二个...这一操作可以通过线段树来完成.线段树的结点包括3个值:l(区间左端点),r…
题意:有一个输入序列,每次操作要把b[i]插入到第a[i]个,在第a[i]个后面的要后移,问最后序列. n<=200000 思路:顺序来只能用splay维护 考虑倒序,对于插入到第K个位置,在线段树二分第K个0的位置,类似于主席树 将其插入后将这个位置修改为已经有数 单点修改 ..]of longint; a,b,c:..]of longint; n,i,k:longint; procedure pushup(p:longint); begin t[p]:=t[p<<]+t[p<&…
[poj2828]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 here…
线段树 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…
可耻的看了题解 巧妙的思维 逆序插入,pos 代表的意义为前面要有pos个空格才OK: 证明:仔细思考一下就觉得是正确的,但是要想到这种方式还是要很聪明,空格是前面的几个数字所形成的,所以要特地留出来,因为这几个空格是既定的事实 线段树实现 线段的意义:当前线段留的空格数,满足区间和性质 代码如下: #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #includ…
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…
Description 输入n个有序对< pi, vi >,pi表示在第pi个位置后面插入一个值为vi的人,并且pi是不降的.输出最终得到的v的序列 Input 多组用例,每组用例第一行为有序对组数n,之后n行每行两个整数表示一个有序对,以n=0结束输入 Output 对于每组用例,输出最后得到的序列 Sample Input 4 0 77 1 51 1 33 2 69 4 0 20523 1 19243 1 3890 0 31492 Sample Output 77 33 69 51 314…
飞翔 问题是这样的:现在有n个人要买票,但是天黑可以随便插队.依次给出将要买票的n个人的数据信息.包含两项:pos,当前第i号人来了之后他肯定要插入到pos这个位置,如果当前pos无人,那最好了,直接把他插入即可.但如果pos这个位置有人了,从现实意义上讲,第i号人插入之后,相当于他 后面的人在原来的基础上都往后挪了一个位置!(ps:这就是为什么人们都讨厌插队的人的原因啊!!!) 每一个人都携带一个val值,当n个人全部确定下 来之后输出val序列.   分析:可以这样想,就算是你先到的,先排到…
题目地址: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…