PT07Z wrong answer

This is the link to the question SPOJ.com - Problem PT07Z . And Link to my solution TanPlumGreatargus - Replit .

I am not getting for what case is my answer wrong?

INPUT:

5
1 2
2 3
1 4
4 5

YOUR OUTPUT:
2

CORRECT OUTPUT:
4

In line 51, it should be

if\ (mx < dist[i])

instead of

if\ (mx > dist[i])

Rest looks correct and should get an AC.

1 Like

Thanks! Silly mistake, It was!

1 Like