WA IN ENTEXAM||PLEASE HELP ||

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 :pensive:. 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

I’ve already explained, in your duplicate thread.

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 CodeChef: Practical coding for everyone

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

sir please see new submission i have send link above this :point_up_2:
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! :grinning: :heart_eyes:
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
:grinning: :grinning: :grinning:

2 Likes