ORDERSET  Order statistic set
English  Vietnamese 
In this problem, you have to maintain a dynamic set of numbers which support the two fundamental operations
 INSERT(S,x): if x is not in S, insert x into S
 DELETE(S,x): if x is in S, delete x from S
and the two type of queries
 KTH(S) : return the kth smallest element of S
 COUNT(S,x): return the number of elements of S smaller than x
Input
 Line 1: Q (1 ≤ Q ≤ 200000), the number of operations
 In the next Q lines, the first token of each line is a character I, D, K or C meaning that the corresponding operation is INSERT, DELETE, KTH or COUNT, respectively, following by a whitespace and an integer which is the parameter for that operation.
If the parameter is a value x, it is guaranteed that 0 ≤ x ≤ 10^{9}. If the parameter is an index k, it is guaranteed that 1 ≤ k ≤ 10^{9}.
Output
For each query, print the corresponding result in a single line. In particular, for the queries KTH, if k is larger than the number of elements in S, print the word 'invalid'.
Example
Input 8 I 1 I 1 I 2 C 0 K 2 D 1 K 1 K 2 Output 1 2 2 invalid
hide comments
icpc_628:
20191026 09:21:31
My PBDS always WA ， Why？ 

umang696:
20190908 00:55:32
Is there any issue between Oracle and Spoj????? 

abhi2402:
20190617 09:51:15
Just use C++ PBDS, got the AC using 20 lines of code and in 0.36s. 

kshubham02:
20190414 13:01:17
@man_of_silence, it is 0<=x<=10^9.


man_of_silence:
20190301 08:28:34
isn't 0 <= x, misleading? Because in the above test cases x is negative. 

nikhil2504:
20181229 13:58:30
nice problem 

k0walsk1:
20180924 14:36:51
Policy Based Data Structures are so OP lul 

badboy_1496:
20180811 09:30:22
AC in one go ,,,,,use of BIT and binary search and cordinate compression!!!! Last edit: 20180811 09:31:31 

luka_dzimba911:
20180725 03:56:04
Can anyone explain how to get under 0.5 s i have 0.84s and have been using AVL no optimizations . Thanks in advance 

kaushalag29:
20180623 07:11:35
@Duc Plz check my solution #id 21882541.Getting WA after 5th test case.Is it due to getchar()? 
Added by:  Duc 
Date:  20081028 
Time limit:  0.300s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  © VNOI 