-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode1477673.cpp
More file actions
48 lines (35 loc) · 832 Bytes
/
code1477673.cpp
File metadata and controls
48 lines (35 loc) · 832 Bytes
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <set>
using namespace std;
set<int64_t> s;
void raspon(int64_t a, int64_t b) {
auto donja_granica = s.lower_bound(a);
auto gornja_granica = s.lower_bound(b);
if(*gornja_granica != b)
gornja_granica--;
if(donja_granica == s.end() || *donja_granica >= b) {
cout << '0' << '\n';
return;
}
cout << *gornja_granica - *donja_granica << '\n';
return;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
while(n--) {
int64_t a, b, x;
char c;
cin >> c;
if(c == 't') {
cin >> x;
s.insert(x);
} else if(c == 'i') {
cin >> a >> b;
raspon(a, b);
}
}
return 0;
}