Help in Entrance Exam

https://www.codechef.com/viewsolution/15433615 .My solution for Entrance Exam.Getting a WA.PLEASE HELP!!!

There -

Input
1
4 3 3 10
10 10 4
10 10 10
10 10 10
10 5
Your Output
Impossible
Correct Output
10

Suffering from out of index error it seems to me.

fixed that problem.Still getting WA

Updated link for code please :slight_smile:

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

Are you sure that your comp function will work fine on alrge values, greater than range of int? Asking because of-

return (*(int*)b-*(int*)a);

I made all the long long ints , ints now.int can store 4x10^9,which is the maximum value that will appear in this problem.BUT im still getting a WA.

Check your sort function. Try this-

Instead of descending order, sort in ascending order and check from N-K-1 element and seregy’s marks.

If that doesnt help, goto c++ compiler and replace your qsort with in built sort. Again, check with N-k-1 element.

I think step 2 will give you AC. Some thigns about C are quite peculiar hence why I avoid it.

The problem is with your sort function comaparator function and the way you calculate minmark…

Use following comparator instead of your comp

int cmp (const void * a, const void * b){

if( *(long long int*)a - *(long long int*)b < 0 )return -1;

if( *(long long int*)a - *(long long int*)b > 0 )return 1;

return 0;

}

Please ACCEPT and UPVOTE this answer… :slight_smile:

Here’s a link to your


[1] now working properly...

Feel free to ask anything.... :)


  [1]: https://www.codechef.com/viewsolution/15438546

Thanks a lot.Upvoted :D.

I haven’t learned how to code in C++ yet.Still,thanks a lot