<PREV Problem:
NEXT>
Solved by 24 users: KZ, JohnJones_001, vi002, WsemirZ, Rizvanov, Norbert, Philip_PV, Agarb, defrager, UdH-WiNGeR, RAVEman, maciejk, DAV, Kuznetsov_S, kornakovBSU, abortmozga.ru, Dest, fetetriste, ripatti, ethanhunt, okoled, NIGHTFIT, steven, murphy.
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 

Database Query Engine

Time limit = 4 second(s)

Memory limit = 64 Mb

Stock market securities have many properties such as floating price, volatility, liquidity, etc. Also one may estimate their mean profitability, growth potential, etc.

WebMarket is a managing company of a stock exchange. It provides trading facilities for stock brokers and traders, services for issue and redemption of securities as well as other financial instruments and capital events including payment of income and dividends.

WebMarket analysts introduce a new market index called reliability. High reliability value implies low risk of buy, but also lower profit estimate.

WebMarket analysts decide to make the reliability index public and provide a service of buying the security with the K-th highest value of reliability. According to WebMarket analysts this instrument will attract more clients and increase the market turnover.

Reliability estimation algorithms are already baked. Your task is to write a program that manipulates the reliability index list. The securities are listed in the decreasing order of reliability. The securities with equal reliabilities are listed in the increasing order of their ids.

Securities in the Webmarket database have three attributes:

For each new security, the value of id is automatically assigned to the next available id. Initial value of reliability is 0. If a security is removed its id is never reused.

The following requests should be supported: issuing a new security, removing a security from the database, changing the value of reliability for an existing security, and finding the K-th security in the reliability index list.

Output

The first line contains the number of requests N (0 ≤ N ≤ 100000). The next N lines contain requests, one per line. A request has one of the following four forms.

Your program should respond with one line for each request.

Input#1
17
ISSUE aaa
FIND 10
ISSUE bbb
ISSUE ccc
RELIABILITY aaa 10
RELIABILITY bbb 30
RELIABILITY ccc 20
RELIABILITY xxx 20
FIND 1
FIND 2
FIND 0
ISSUE eee
ISSUE fff
FIND 3
FIND 111
DELETE bbb
FIND 0
Output#1
CREATED 0 0
OK aaa 0 0
CREATED 1 0
CREATED 2 0
OK 0 10
OK 1 30
OK 2 20
BAD REQUEST
OK ccc 2 20
OK aaa 0 10
OK bbb 1 30
CREATED 3 0
CREATED 4 0
OK eee 3 0
OK fff 4 0
OK 1 30
OK ccc 2 20


Author:
ACM ICPC 2008-2009, Moscow Subregional Contest, Moscow, October 26, 2008.
Artem Voroztsov
26 October 2008

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 190ms

SW soft NIX
ID = 23.20.13.165