LoC June 17 Harry and Magical Number!

Whats wrong with my code to HARRY AND MAGICAL NUMBER?!
It even passed the sample case and some manual inputs which I tested it with so why am I getting WA.

Problem: CodeChef: Practical coding for everyone
Check my code (C):
#include <stdio.h>
int main()
{
int t;
scanf(“%d”,&t);
while(t–)
{
int array[100], minimum, size, c,s;
scanf(“%d%d”,&size,&s);
for ( c = 0 ; c < size ; c++ )
{
scanf(“%d”, &array[c]);
}

minimum = array[0];

for ( c = 1 ; c < size ; c++ ) 
{
    if ( array[c] < minimum ) 
    {
       minimum = array[c];
    }
} 
    if((minimum*size)==s)
    {
        printf("%d\n",minimum);
    }
    else
    {
        printf("-1\n");
    }
}
return 0;

}

Your code fails on the test case

1

2 5

2 3

in the above given test value of K (as stated in question) is 3.

in your code u are only checking for the if the minimum number is K or not. Try changing your code dude…

Try this input:

1
3 9
1 12 18
Your Output:
-1
Correct Output:
4
1 Like

Hey…
You could try my solution…
I didn’t try it whether it is correct or not, because i didn’t find link to this question in practice problems.

I used Binary Search to solve this problem.and here is my solution.
Please try to submit it and tell me also whether it is right or wrong.

Thanks a lot stark!

My solution is correct. I submitted it and got AC.

my code also output -1 if i input
3 9
1 12 18
but got AC
Don’t Know about your Testcase :3 :3