question link >> CodeChef: Practical coding for everyone

my solution >> CodeChef: Practical coding for everyone

4 1 1 1 1 4 will give wrong ans.

Expected: 2

Output: 0

## Input

## 1

8

1 3 1 1 1 1 3 1

## output

0

hey can you tell me why my code is not working . it is working on sample test cases .

```
#include<vector>
#define loop(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(void){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int* input = new int[n];
for(int i=0;i<n;i++){
cin>>input[i];
}
int maxi = *max_element(input,input+n);
vector<int> pos;
for(int i=0;i<n;i++){
if(maxi == input[i]){
pos.push_back(i);
}
}
int count=0;
int k=n;
int half = n/2;
if(pos.size() == n){
cout<<"0"<<endl;
}else{
for(int i=1;i<k;i++){
int flag=1;
for(auto x : pos){
if((x+i)%n < half){
flag=0;
break;
}
}
if(flag == 1){
count++;
}
}
cout<<count<<endl;
}
}
return 0;
}
```

@devgoyal04 @gauravdatt2000

The ans for test case:

1

26

1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5

Expected : 2

output for many AC : 0

The author of the ques must look into it.

What are the 2 possible sequences for A?

I do not think that any sequence A exists.

Hey @anon86902332 consider the test case

1

8

1 1 1 1 2 1 1 1

Expected: 4

Output: 3

Problem: It seems you are missing the case where K could be 0 also.

Hope this helps!

@everule1

1

26

1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5

In this case if it is shift by 14 position

then we ll get

1 1 1 1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 5 1

Now, state 1: is above mentioned

and next state2 is : the one more shift right state

So in total we got 2 .