Wrong Answer in "GSUB" for first subtask

Question:-

/*

       ___         ___           ___           ___                       ___     
      /\  \       /\  \         /\  \         /\__\          ___        /\  \    
      \:\  \     /::\  \       /::\  \       /:/  /         /\  \      /::\  \   
  ___ /::\__\   /:/\:\  \     /:/\:\  \     /:/  /          \:\  \    /:/\ \  \  
 /\  /:/\/__/  /::\~\:\  \   /::\~\:\  \   /:/__/  ___      /::\__\  _\:\~\ \  \ 
 \:\/:/  /    /:/\:\ \:\__\ /:/\:\ \:\__\  |:|  | /\__\  __/:/\/__/ /\ \:\ \ \__\
  \::/  /     \/__\:\/:/  / \/_|::\/:/  /  |:|  |/:/  / /\/:/  /    \:\ \:\ \/__/
   \/__/           \::/  /     |:|::/  /   |:|__/:/  /  \::/__/      \:\ \:\__\  
                   /:/  /      |:|\/__/     \::::/__/    \:\__\       \:\/:/  /  
                  /:/  /       |:|  |        ~~~~         \/__/        \::/  /   
                  \/__/         \|__|                                   \/__/    

*/

#include <bits/stdc++.h>
using namespace std;
long long int getMaxLength(long long int arr[],long long int n)
{
  long long   int l = n;
  long long   int i = 0, maxlen = 0;
    while (i < l)
    {
        long long int j = i;
        while (i+1 < l &&
             (abs(arr[i] - arr[i + 1])>0))
        {
            i++;
        }
          long long   int currLen = i - j + 1;
            if (maxlen < currLen)
                maxlen = currLen;

            if (j == i)
                i++;
    }
    return maxlen;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        long long int q,i,j,cnt=0,n,p1,p2,x,y;
        cin>>n>>q;
        long long int a[n];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        for(j=0;j<q;j++)
        {
            cin>>x;
            cin>>y;
            a[x-1]=y;
            cout<<getMaxLength(a,n)<<endl;

        }

    }
}

any test case for which it’ll fail?

1
10 2
1 2 3 2 4 4 5 4 4 3
2 2
7 4
Ans 1: 8
Ans 2: 6
Your solution is giving: 5 for both.
Check my solution .
https://www.codechef.com/viewsolution/39259314

1 Like

Subsequences need not to be continuous

2 Likes

thanks !

THANKS A LOT!