Help me to find the logical error in my code

Hey guys can anybody help me to find the logical error in my code for the PRACTICE question https://www.codechef.com/problems/CHFM

#include
using namespace std;

int main() {
int t,sum=0,x,i,j;float inimean,finmean,sumf=0;
cin>>t;int n;
for(int z=0;z<t;z++){
cin>>n;
int a[n];
for(int k=0;k<n;k++){ //storing into array
cin>>a[k];
}

for( j=0;j<n;j++){
        sum+=a[j];              
    }
 inimean=sum/n;          //Finding initial mean

for( i=0;i<n;i++){
   
    for( j=0;j<n;j++){
         if(i!=j){
        sumf+=a[j];
    }
     finmean=sumf/(n-1);
    }

if(inimean==finmean){
    cout<<(i+1)<<endl;}
else
    cout<<"Impossible";

}

return 0;

}}

Maybe you have to put that if else statements[Have to use break after printing the answer] after the line finmean = sumf/(n-1)

Blockquote

if(inimean==finmean){
cout<<(i+1)<<endl;}
else
cout<<“Impossible”;

Blockquote

But, this logic gonna have high time complexity.
Try to optimize Your approach.
There’s an easy way to do this problem.Try to think about it. :slight_smile:

1 Like

Tha is dudumahesh…