TOPIC

Wrong answer (35%)

SHUVRA ADITYA (IIT_NSTU) (͡ ° ͜ʖ ͡ °) asked 6 months ago

Here is my code.

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, q, typ, pos, val, x, a, b, mn, mx, c, tmp;
    cin >> n >> q;
    std::vector<int>num(n);
    for(int i=0; i<n; i++)
    {
        cin >> num[i];
    }

    for(int i=0; i<q; i++)
    {
        c=0;
        cin >> typ;
        if(typ==1)
        {
            cin >> pos >> val;
            num[pos-1]=val;
        }
        else if(typ==2)
        {
            cin >> x >> a >> b;
            if(a<b)
            {
                mn=a;
                mx=b;
            }
            else if(a>=b) 
            {
                mx=a;
                mn=b;
            }
            for(int j=mn-1; j<=mx-1; j++)
            {
                if(num[j]>x)
                {
                    c++;
                }
            }
            cout << c << endl;
        }
    }
    return 0;
}

I don't know what's the wrong with it. I will be greateful if you help me out. Thanks in advance!!!

Remember not post solutions. Your post may be reviewed by our moderators.

  • feodorv replied 6 months ago

    I see no error in your code. To speak the truth, your code should give TLE, not WA35...