Not able to pass testcases

I am able to get the same output as given sample input but not able to pass test cases.Don’t know where i am doing mistake please help.

please share your code

#include<iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int m;
        cin>>m;
        int arr[m];
        for(int j=0;j<m;j++)
        {
            cin>>arr[j];
        }
        int cs=0;
        int ms=0;
        for(int j=0;j<m;j++)
        {cs=cs+arr[j];
        if(cs<0)
        {
            cs=0;
        }
        ms=max(cs,ms);
        

        }
       
        int cs1=0;
        int ms1=0;
        int sum=0;
        for(int k=0;k<m;k++)
        {sum=sum+arr[k];
        cs1=cs1-arr[k];
        if(cs1<0)
        {
            cs1=0;
        }
        ms1=max(cs1,ms1);

        }

     
        int mac=max(ms,(sum-(-ms1)));
        cout<<mac;
        
    }
	return 0;
}

Please reply as i have also posted code

hi vikash
your code will not work large inputs and you were not considering the inputs for more than one test case
your code is not working for the following test cases
9
8
-1 40 -14 7 6 5 -4 -1
8
10 -3 -4 7 6 5 -4 -1
7
8 -8 9 -9 10 -11 12
9
11 10 -20 5 -3 -5 8 -13 10
100
81 13 -18 9 40 -6 47 -14 92 77 20 96 70 85 -1 10 97 56 35 48 33 39 63 -5 79 41 -13 32 -11 -4 43 5 -20 8 24 -10 61 98 100 -16 66 86 88 89 -3 25 58 37 42 51 36 -19 22 60 23 93 76 94 50 15 46 -12 18 -8 64 62 12 6 44 2 28 27 3 95 38 59 4 91 -17 1 45 87 0 -15 53 74 99 65 78 84 57 -2 17 -9 7 29 11 30 52 -7
100
87 24 1 11 83 -3 86 -19 67 80 13 70 84 -6 20 92 81 35 63 -12 41 46 39 27 57 12 52 30 38 -2 21 77 72 9 25 54 29 75 73 85 -14 76 60 82 6 49 40 89 32 59 74 26 97 55 47 66 0 15 7 64 -1 28 98 100 48 33 -5 5 -18 51 56 78 58 43 -4 22 14 -20 91 -13 99 2 -8 -10 94 36 -15 -11 37 3 65 34 62 8 50 16 31 45 -9 90
100
41 66 91 -10 87 28 31 35 69 79 53 84 46 98 56 94 7 20 37 12 27 -11 -17 6 80 92 89 100 47 5 21 11 8 22 23 64 50 55 -15 85 51 45 82 48 71 15 -1 26 43 18 57 14 -5 72 30 68 67 -14 42 60 34 97 83 19 9 29 -4 -3 76 -20 88 -9 62 16 0 -7 73 -6 99 25 81 36 40 32 77 44 17 3 52 58 74 86 -8 93 95 54 61 63 96 49
100
32 -16 -6 14 86 66 69 28 88 87 11 0 7 3 37 60 62 -19 79 43 12 73 70 19 44 33 85 71 34 18 -15 54 -3 -12 21 83 52 91 75 81 95 4 49 63 82 58 72 36 -11 84 78 15 6 -4 -20 25 53 13 5 99 2 94 -2 89 26 8 55 -17 29 -5 9 31 45 -9 74 97 90 24 10 48 27 77 65 61 20 93 41 23 92 40 80 57 68 76 22 98 56 -7 -1 64
100
14 -9 -3 82 79 67 25 78 10 38 22 -20 28 84 -15 89 98 26 57 1 6 63 92 4 52 5 46 54 -2 3 74 -12 -13 100 55 24 81 60 35 -11 -6 -4 32 -14 77 37 45 34 33 96 97 27 48 36 -16 66 -18 -19 43 51 29 21 64 12 -17 18 19 71 91 41 -8 2 -5 44 86 94 7 47 31 53 -7 16 68 15 65 88 42 93 83 40 50 58 49 -1 80 17 13 30 85 99

instead refer to this approach
Approach :
For finding the Maximum Contiguous sum we are using the kadane’s algorithm. But in the question the array is circular that means the maximum sum can be of elements which are a part of the wrapping or not. So,
There can be two cases for the maximum sum:
Case 1: The elements that contribute to the maximum sum are arranged such that no wrapping is there. Examples: {-10, 2, -1, 5}, {-2, 4, -1, 4, -1}. In this case, Kadane’s algorithm will produce the result.

Case 2: The elements which contribute to the maximum sum are arranged such that wrapping is there. Examples: {10, -12, 11}, {12, -5, 4, -8, 11}. In this case, we change wrapping to non-wrapping. Let us see how. Wrapping of contributing elements implies non wrapping of non contributing elements, so find out the sum of non contributing elements and subtract this sum from the total sum. To find out the sum of non contributing, invert sign of each element and then run Kadane’s algorithm. Our array is like a ring and we have to eliminate the maximum continuous negative that implies maximum continuous positive in the inverted arrays.