https://www.codechef.com/viewsolution/36137582

I have used this logic

IF my total possible score score will be greater than at least n-k students total score than i will be selected .
else impossible .

yes

Itâ€™s a WA not compilation error.

1 Like

can you tell why its wrong

Iâ€™m sorry. Iâ€™m a bit busy . So it wonâ€™t be possible for me to read the question and your logic in your code. You may tag anyone from top contributors to help you.

1 Like

4 Likes

I have changed (long long int compare) to (int compare) still error is coming I think there may be something wrong in logic part as well
my logic :-
If Sergey gets total possible score more than at least n-k students total score then he will be selected
else it is impossible

Please, whenever you say â€śIâ€™ve changed the codeâ€ť, just post the link to the new submission.

4 Likes

new submission https://www.codechef.com/viewsolution/36145680

1 Like

Thankyou. This is failing for the exact same reason, for the exact same testcase, as I originally explained.

Just replace your `compare` function with the one I suggested.

4 Likes

new submission
https://www.codechef.com/viewsolution/36146171

1 Like

i have done according to what you told

No you havenâ€™t XD

Your `compare`:

``````int compare(const void *p1,const void *p2)
{   int arg1 =*(long long int *)p1;
int arg2 =*(long long int *)p2;
if(arg1<arg2) return -1;
if(arg1>arg2) return 1;
return 0;
}
``````

What I asked you to do:

``````int compare(const void *p1,const void *p2)
{
const long long int p1AsLong = *(long long int *)p1;
const long long int p2AsLong = *(long long int *)p2;
if (p1AsLong < p2AsLong)
return -1;
if (p1AsLong > p2AsLong)
return +1;
return 0;
}
``````
2 Likes

am sorry i did mistake again

Thanks a lot sir!
you are awesome thanks for help . I am so happy . You have taught very important things . I will be forever thankful to you you .
https://www.codechef.com/viewsolution/36146297

2 Likes