hiho week 104 register

Ended

Participants:220

Verdict:Accepted
Score:100 / 100
Submitted:2016-06-25 23:03:08

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
#include<cstdio>
#include<set>
#include<cstring>
std::set<int> s;
int n,a,b;
char c;
int main(){
    scanf("%d\n",&n);
    std::set<int>::iterator it;
    while(n--){
        scanf("%c",&c);
        if(c=='I'){
            scanf("%d%c",&a,&c);
            s.insert(a);
        }
        else if(c=='Q'){
            scanf("%d%c",&a,&c);
            it=s.upper_bound(a);
            printf("%d\n",*(--it));
        }
        else if(c=='D'){
            scanf("%d%d%c",&a,&b,&c);
            it=s.lower_bound(a);
            while(it!=s.end()&&*it<=b)
                s.erase(it++);
        }
    }
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX