hiho week 103 register

Ended

Participants:252

Verdict:Accepted
Score:100 / 100
Submitted:2016-06-23 16:23:07

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
#include <iostream>
#include <cstdio>
#include <set>
using namespace std;
int main() {
    set<int> S;
    int N;
    cin >> N;
    char op; int num;
    for (int i = 0; i < N; ++i) {
        cin >> op >> num;
        if (op == 'I') S.insert(num);
        else {
            set<int>::iterator it = S.lower_bound(num);
            if (*it == num) cout << num << endl;
            else cout << *(--it) << endl;
        }
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX