hiho week 103 register

Ended

Participants:252

Verdict:Accepted
Score:100 / 100
Submitted:2016-06-18 22:10:46

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
#include <set>
#include <iostream>
using namespace std;
set<int> S;
int n,maxs=-2147483647;
int main(void){
    cin>>n;
    while (n--){
        char ch;
        int p;
        cin>>ch>>p;
        if (ch=='I'){
            S.insert(p);
            maxs=max(maxs,p);
        }
        if (ch=='Q'){
            set<int>::iterator it;
            if (p>maxs)
                it=--S.end();
            else it=S.lower_bound(p);
            while (*it>p) --it;
            cout<<*it<<endl;
        }
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX