Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include<iostream>
  2. #include<set>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n,d,a,c,p=0;
  9.     set <int> z;
  10.     set <int> :: iterator it1, it2;
  11.     cin>>n>>d;
  12.     for(int i = 0; i<n ; i++)
  13.     {
  14.         cin>>c>>a;
  15.         if(c==1)
  16.         {
  17.             z.insert(a);
  18.             it1=z.find(a-d)
  19.             it2=z.find(a+d)
  20.             if(it1!=z.end())
  21.             {
  22.                 p++;
  23.             }
  24.             if(it2!=z.end())
  25.             {
  26.                 p++;
  27.             }
  28.         }
  29.         else
  30.         {
  31.             if(it1!=z.end())
  32.             {
  33.                 p--;
  34.             }
  35.             if(it2!=z.end())
  36.             {
  37.                 p--;
  38.             }
  39.             z.erase(a);
  40.         }
  41.             if(p>0)
  42.             {
  43.                 cout<<"TAK";
  44.             }
  45.             else
  46.             {
  47.                 cout<<"NIE";
  48.             }
  49.        
  50.     }
  51.    
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement