Closing the Tweets
Problem Code: TWTCLOSE
I tried this approach and it dint work… ?? Atleast when i did a dry run for the test cases it is correct…but the compiler is not printing the desired result .
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,k;
cin>>n>>k;
int maxi = 0;
vector<int>s(n);
while(k--)
{
string s1,s2;
cin>>s1;
if(s1 == "CLOSEALL")
{
fill(s.begin(),s.end(),0);
maxi = 0;
}
if(s1 == "CLICK")
{
cin>>s2;
cout<<s2<<endl;
int temp = stoi(s2);
cout<<temp<<endl;
if(s[temp] == 0)
{
s[temp] = 1;
maxi++;
}
else
{
s[temp] = 0;
maxi--;
}
}
cout<<maxi<<endl;
}
return 0;
}