Kaushik and his company...


Problem Statement :

https://www.codechef.com/KOPC2016/problems/K16I

Problem Solution :

#include<bits/stdc++.h>

using namespace std;

int main()
{
   long int n,q,x,i,ans;
   char ch;
   cin>>n>>q;
   int a[n]={0};
   next:
   while(q--)
   {
       cin>>ch;
       cin>>x;
       if(ch=='C')
       {
           if(a[x]==0)
             a[x]=1;
           else
             a[x]=0;
       }
       else
       {
           for(i=x;i<n;i++)
           {
               if(a[i]==1)
               {
                   cout<<i<<endl;
                   goto next;
               }
           }
           cout<<"-1"<<endl;
       }
   }
    return 0;
}

No comments:

Post a Comment