Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <set>
- using namespace std;
- ifstream f("set.in");
- ofstream g("set.out");
- set <int> S;
- int n,op,x,y,t;
- int main()
- {
- f>>n;
- for(int i=1;i<=n;++i)
- {
- f>>op;
- if(op==1)
- {
- f>>x;
- S.insert(x);
- }
- if(op==2)
- {
- f>>x;
- t=*S.lower_bound(x);
- if(S.empty()) /// Daca setul S e vid
- g<<-1<<'\n';
- else
- if(x<=*S.rbegin()) /// Daca x se afla in set
- g<<t<<'\n';
- else
- g<<-1<<'\n';
- }
- if(op==3)
- {
- f>>x>>y;
- if(y>=*S.begin())
- while(S.lower_bound(x)!=S.end()&&*S.upper_bound(x)<=y)
- S.erase(*S.lower_bound(x));
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement