Accepting wrong solution

Describe your issue

in the recent contest starters 202 , problem Min-Max Deque DEQMNMX is accepting the all the test case with wrong solution it should give tle

Screenshot

Additional info

accepted wrong solution :

//// CP tempalte////
#include<bits/stdc++.h>
using namespace std;

define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
define MOD 1000000007
define MOD1 998244353
define INF 1e18
define nl “\n”
define pb push_back
define ppb pop_back
define mp make_pair
define ff first
define ss second
define PI 3.141592653589793238462
define set_bits __builtin_popcountll
define sz(x) ((int)(x).size())
define all(x) (x).begin(), (x).end()
define loop(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

#ifndef ONLINE_JUDGE
define debug(x) cerr << #x <<" == "; _print(x); cerr << endl;
#else
define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template void _print(T arr,size_t n) { cerr <<‘[’ ;loop(i, 0, n) cerr << arr[i] << " “;cerr<<‘]’<<”\n";}
template <class T, class V> void _print(pair <T, V> p);
template void _print(vector v);
template void _print(set v);
template <class T, class V> void _print(map <T, V> v);
template void _print(multiset v);
template <class T, class V> void _print(pair <T, V> p) {cerr << “{”; _print(p.ff); cerr << “,”; _print(p.ss); cerr << “}”<<‘\n’;}
template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << “]”<<‘\n’;}
template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << “]”<<‘\n’;}
template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << “]”<<‘\n’;}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << “]”<<‘\n’;}
void file_out(){
fastio();
#ifndef ONLINE_JUDGE
freopen(“Error.txt”, “w”, stderr);

#endif
}

////////////////////////////////////////////////////////////////////////////////
// MAIN CODE //
////////////////////////////////////////////////////////////////////////////////

void algorithm(){
int t;cin>>t;
while(t–){

int n , q ;cin>>n>>q;
vector v(n);
loop(i,0,n) cin>>v[i];
vector maxA(n);
vector minA(n);
maxA[0] = v[0];
minA[0] = v[0];
for ( int i = 1 ; i < n ; i++ ){

    if ( i % 2 == 0 ){
        int m =  max(maxA[i-1],v[i]);
        int mi = min(maxA[i-1],v[i]);
        maxA[i] = m;
        minA[i] = mi;
    }
    else{

        int mi= min(minA[i-1],v[i]);
        int m = max(minA[i-1],v[i]);
        maxA[i] = m;
        minA[i] = mi;
    }

   
    
} cout<< minA[n-1]<<" ";

while (q--){

    int p , x;
    cin >> p >> x ;

    

    if (v[p-1] == x){
        cout<< minA[n-1]<<nl;
        continue;
    }
    v[p-1] = x ;
    if ( p == 1 ) maxA[0] = minA[0] = v[0];

    for ( int i = max(1, p-1) ; i < n ; i++ ){

        int maxA_prev = maxA[i];
        int minA_prev = minA[i];
        if ( i % 2 == 0 ){
            int m =  max(maxA[i-1],v[i]);
            int mi = min(maxA[i-1],v[i]);
            maxA[i] = m;
            minA[i] = mi;
        }
        else{

            int mi= min(minA[i-1],v[i]);
            int m = max(minA[i-1],v[i]);
            maxA[i] = m;
            minA[i] = mi;
        }
        if ( maxA[i] == maxA_prev && minA[i] == minA_prev ) break ;/// beacuse now rest is same as previous

   
    
} cout<< minA[n-1]<<" ";


    



}cout<<nl;

}

}

int main() {
file_out();
///////////////////input space ///////////////

algorithm();

return 0 ;
}