POINTS Why am I getting a wrong answer?

Hello,
I was stuck at the points problem (link given)


My solution link is
http://www.codechef.com/viewsolution/1495244
I have tried all possible test-cases and the program works correctly. Please tell me where I am going wrong. Also it would be very helpful if you could just post one or two test cases where my code fails and I would try to figure out on my own what went wrong.
Thanks a lot

in your main function, there are printf("\n") that shouldn’t probably be here. :slight_smile:

Hey still not working…
This is the modified solution link.
http://www.codechef.com/viewsolution/1495528
Please tell me if there is such minor mistake of formatting… I have been struggling on this problem for a very long time.
Thanks

Result of a very quick scan:

It seems that you need to re-initialise hash between test cases.

Have already done that also in the init() function which is called at the end of every iteration :frowning:
Sorry for the trouble but please HELP !!!

just a question (i’m curious ^^) : why reimplementing the standard qsort() function ?

My quick scan was a bit too quick. I missed the init. Sorry about that.

I found a test case for which your program produces an incorrect answer:

1

4

1 1

1 2

1 3

1 4

I think it should result in 3.00, but your program prints 5.00

Your program may also crash when there are (e.g.) 50000 points. You can generate a test case like that yourself…

Good luck.

1 Like

Hey thanks a lot!! Really helped…

Please tell me if there is such minor mistake of formatting… I have been struggling on this problem for a very long time.
Thanks