Doubt in Greedy Student question

My solution link: Solution: 41525777 | CodeChef
I was trying greedy student for 5 marks and got WA. Can somebody help in finding out mistake in my code.
My approach: First student will choose points forming convex hull. And for second student i was also finding convex hull but by removing one point included in convex hull of first student and printing the one with max area.
My approach is very similar to one in editorial and I also say other people solution and they were also almost same.
You can refer below solution, he also used the same approach but got AC.
Solution: 41457008 | CodeChef

Yup that’s my solution.


why j-c instead of j?

for i in range(len(firstHull)):
  for j in range (n):
    if (firstHull[i]==points[j]):
    secondHull = convex_hull_graham(p)
    temp = polygonArea(secondHull)

This is my last for loop and in p i am appending all the points except when jth point in points is equal to ith point of first convex hull. That means my p contains n-1 point.

You should exclude the jth index of points not j-c.

Oh got my mistake…i was doing this in c++ and implemented same way in python.
There is always something which I regret after every contest XD.

Your convex hull implementation is also wrong. You can check. Your AC code.

1 Like

you should


@akshitm16 LoL

1 Like