-1

everyone! While I was solving the problems from cses.fi I came across the one that I totally couldn't understand. I searched the Internet and found the solution with DP along subsets, but still wasn't able to realize why it works. The problem is below with its solution... https://cses.fi/problemset/task/1653 https://cses.fi/book/book.pdf (page 103 - 104)

In short, the author offers to count for each subset to values: the minimum number of rides requiered ('rides(S)') and for that number of rider the minimum weight of the last group of people ('last(S)'). And if we consider some set S then we need to take some its element p, extract it from S, recount required values rides(S\p) and last(S\p) trying to add the element p to the smallest group with weight last(S\p) if it's possible and to create a new group for p otherwise. Then we need to repeat that algorithm for all possible p in the set S and take the minimum possible pair {rides(S\p);last(S\p)}.

Please, tell me why do we get the requiered values for S during the algorithm I described. I don't understand why it goes through all the possible options, why it's exhaustive.

I tried to prove its accuracy, but I'm not so good at maths.

1 Answer 1

3

I will share with you how to prove this by a heuristic way.

If there is a god...

If you have n people and there is a god who can tell you the minimum ride with all n - 1 people possibilities and the minimum total weight of the last group.

And we can get the right answer with n people by checking every n - 1 people case. You can prove this by contradiction: if there is a right answer not included by this, that means:

  1. The god is wrong, which is contradicted by our definition(God is always right)
  2. The god is right, but the right answer is not included in this way. This is wrong because for the minimum ride solution, the arrangement of the first n - 1 people is included in the god's answer and we checked all the possibilities of the last people so it is included.

If there is no god...

Now, you need to calculate what God provided you with before — the answer to all n—1 people's possibilities.

Think about there is a less powerful god who can tell you the answer to all n - 2 people's possibilities. With the help of the less powerful god, we can calculate the answer of n - 1 people possibilities by the same way.

Then the less power god who can solve n - 2 disappears and you can only find the god who helps you on n - 3. De javu.

The god disappears all the way down to 1 person. Okay, should we need a god to solve the problem with only 1 person? We can do this by ourselves: for every person, we need 1 ride and the minimum weight of the last group is the weight of that person.

To sum up, you can prove that the solution is right.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.