Buy And Sell BIT code Problem Wrong Answer

Could not verify the problem in logic of the present at location https://ide.codingblocks.com/s/157893. Getting wrong answer for both of the test cases.

Why are you doing so much? Its a simple problem. Here’s what needed to be done.

  1. When you have β€˜+’ , just update quantitiy in map and update BIT with 1.
    2.When you have β€˜-’ , just decrease quantitiy and update BIT with -1.
    3.When you have β€˜?’ , just call your query function. Thats it!

if(c==’+’)

        {
            string s;
            cin>>s;
            quant[s]++;
            update(price[s],1);
        }

        else if(c=='-')
        {
            string s;
            cin>>s;
            if(quant[s]>0)
            {
                update(price[s],-1);
                quant[s]--;
            }

        }
        else if(c=='?')
        {
            int i;
            cin>>i;
            cout<<query(i+1)<<endl;
        }

Please have a look here to see sample implementation.