Buy Tickets Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 19012   Accepted: 9442 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…
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, he ha…
题目链接:poj 2828 Buy Tickets 题目大意:给定N,表示有个人,给定每一个人站入的位置,以及这个人的权值,如今按队列的顺序输出每一个人的权值. 解题思路:第K大元素,非常巧妙,将人入队的顺序倒过来看,就是纯第K大问题,然后用树状数组还是线段树就都能够做了. C++ 线段树 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int ma…
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 and there…
题意: 输入一行数字,查询第i个数到第j个数之间的最大值.可以修改其中的某个数的值. 输入: 包含多组输入数据. 每组输入首行两个整数n,m.表示共有n个数,m次操作. 接下来一行包含n个整数. 接下来m行,每行包含一个字母s,两个整数a,b. 当s为’Q’,表示查询第a个数到第b个数之间的最大值. 当s为’U’,表示将第a个数更改为b. 输出: 每次查询输出一个结果,每次输出占一行. 题解: 点修改区间求最值,可以用树状数组模板. 具体见代码—— #include <cstdio> #inc…
Queue Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 862    Accepted Submission(s): 449 Problem Description N people numbered from 1 to N are waiting in a bank for service. They all stand in a…
题目链接:http://oj.xjtuacm.com/problem/14/[分析]二元的逆序对应该都会求,可以用树状数组.这个题要求K元,我们可以看成二元的.我们先从后往前求二元逆序对数, 然后对于每一个数就可以求出在这个数后面的比他小的数的数量.然后我们再加一元时,当前扫到a[i],那么在树状数组中,对于那些比他大的数的 逆序对数+=上一元a[i]的逆序对数. #include <bits/stdc++.h> #define met(a,b) memset(a,b,sizeof a) #d…
小橙子 Time Limit: 2000 MS Memory Limit: 32768 K Total Submit: 2(2 users) Total Accepted: 1(1 users) Rating:  Special Judge: No Description 玻璃小屋里曾经住着一个小橙子.小橙子小小的,性格很直.直性子的小橙子傻乎乎的,还很爱看火影.海贼王什么的.他收藏了很多动画片的光碟,光碟太多了,他打算整理一下. 他口中念念有词:“这个,插入第三个光碟前面,这个,插入第五个光碟…
int find_kth(int k) { , cnt = , i; ; i >= ; i--)/ { ans += ( << i); if (ans >= maxn|| cnt + c[ans] >= k) ans -= ( << i); else cnt += c[ans]; } ; } 题意: 口袋里可以放进不同大小的糖果,也可以拿出不同大小的糖果.查询过程中第k小的糖果体积是多少 输入T,有T组,接下来是输入m次操作 m行输入op和x 当op等于1的时候,…