# Help me in solving AOCC017 problem

### My code

``````#include <stdio.h>
int main()
{
int t;
scanf("%d",&t);

while(t--)
{
int N,i,j;
scanf("%d", &N);
int A[N], B[N];
for(i=0; i<N; i++)
{
scanf("%d", &A[i]);
}
int A_max=A[0];
for(j=0; j<N; j++)
{
scanf("%d",&B[j]);
}
int B_max=B[0];
for(int i=0; i < N; i++)
{
if(A[i]>A_max)
{
A_max=A[i];
A[i]=0;
}
}
//A[i]=0;
for(int j=1; j < N-1; j++)
{
if(B[j]>B_max)
{
B_max=B[j];
B[j]=0;
}

}
//B[j]=0;
int A_sum=0,B_sum=0;
for(i=0;i<N-1;i++)
{
A_sum=A_sum+A[i];
}
for(j=0;j<N-1;j++)
{
B_sum=B_sum+B[j];
}
if(A_sum>B_sum)
{
printf("\nAlice");
}
else if(A_sum<B_sum)
{
printf("\nBob");
}
else
{
printf("\nDraw");
}
}
return 0;
}
``````

Learning course: Solve Programming problems using C
Problem Link: CodeChef: Practical coding for everyone

@nitheesha39
Some logical mistakes were there i have corrected it in your code ,
include <stdio.h>
int main()
{
int t;
scanf(β%dβ,&t);

``````while(t--)
{
int N,i,j;
scanf("%d", &N);
int A[N], B[N];
for(i=0; i<N; i++)
{
scanf("%d", &A[i]);
}
int A_max=A[0];
for(j=0; j<N; j++)
{
scanf("%d",&B[j]);
}
int B_max=B[0];
for(int i=0; i < N; i++)
{
if(A[i]>A_max)
{
A_max=A[i];
//A[i]=0;
}
}
//A[i]=0;
for(int j=0; j < N; j++)
{
if(B[j]>B_max)
{
B_max=B[j];
//B[j]=0;
}

}
//B[j]=0;
int A_sum=0,B_sum=0;
for(i=0;i<N;i++)
{
A_sum=A_sum+A[i];
}
for(j=0;j<N;j++)
{
B_sum=B_sum+B[j];
}
A_sum-=A_max;
B_sum-=B_max;
if(A_sum<B_sum)
{
printf("\nAlice");
}
else if(A_sum>B_sum)
{
printf("\nBob");
}
else
{
printf("\nDraw");
}
}
return 0;
``````

}

1 Like

Donβt know

@dpcoder_007 Thank you