Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<set>
- using namespace std;
- int main()
- {
- int n,d,a,c,p=0;
- set <int> z;
- set <int> :: iterator it1, it2;
- cin>>n>>d;
- for(int i = 0; i<n ; i++)
- {
- cin>>c>>a;
- if(c==1)
- {
- z.insert(a);
- it1=z.find(a-d)
- it2=z.find(a+d)
- if(it1!=z.end())
- {
- p++;
- }
- if(it2!=z.end())
- {
- p++;
- }
- }
- else
- {
- if(it1!=z.end())
- {
- p--;
- }
- if(it2!=z.end())
- {
- p--;
- }
- z.erase(a);
- }
- if(p>0)
- {
- cout<<"TAK";
- }
- else
- {
- cout<<"NIE";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement