hiho week 153 register

Ended

Participants:259

Verdict:Accepted
Score:100 / 100
Submitted:2017-06-04 19:09:11

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
typedef pair<int,int> PP;
int main()
{
    int n,t,p;
    set<PP> price;
    set<PP> prices;
    cin>>n;
    char op;
    while(n--)
    {
        cin>>op;
        if(op=='P')
        {
            cin>>t>>p;
            price.insert(PP(t,p));
            prices.insert(PP(p,t));
        }
        else if(op=='R')
        {
            cin>>t;
            while(price.size()>0&&price.begin()->first<=t)
            {
                PP t;
                t.first=price.begin()->second;
                t.second=price.begin()->first;
                set<PP>::iterator itr=prices.find(t);
                if(itr!=prices.end()) prices.erase(itr);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX