Who Dares To Be A Millionaire

I am getting wrong answer for the solution I’ve submitted but it is working fine on codeblocks.
If anyone could tell me where I am doing wrong.
The link to the problem is:


The code I’ve used is:
#include<stdio.h>
int main()
{
int t,n,i,count;
long long w[1001];
char corr[1000],incorr[1000];
scanf("%d",&t);
while(t>0)
{
t–;
count=0;
scanf("%d\n",&n);
scanf("%s\n",&corr);
scanf("%s\n",&incorr);
for(i=0;i<=n;i++)
scanf("%lld",&w[i]);
for(i=0;i<n;i++)
{
if(corr[i]==incorr[i])
count++;
}
printf("%lld\n",w[count]);
}
return 0;
}

As it is stated in the question "Note that the game was invented by a twisted mind, and so a case where Wi ≥ Wi + 1 for some 0 ≤ i ≤ N − 1 is possible." , which means that W[count] isn’t guaranteed to be the maximum value.

In case Count==n then then w[count] is the answer.

Else you need to find the maximum value of array W till the index COUNT .

I hope it’s clear :p.

link to my submission: https://www.codechef.com/viewsolution/12386384

2 Likes

Thanks nikmul19 got my mistake

//