There are n groups of coins, and the i-th group contains two coins valued at ai and bi. Now you want to pick exactly k coins out of them. However, there is a restriction - you can not pick the second coin valued at bi in the i-th group without picking the other one in the same group. In other words, in the i-th group, you can
- pick none of the two coins;
- pick only the first one valued at ai; or
- pick both of them.
We now want to know the maximum sum of the k picked coins' values, denoted by f(k).
Furthermore, we want to know f(1),f(2),⋯,f(2n).
- pick none of the two coins;
- pick only the first one valued at ai; or
- pick both of them.
We now want to know the maximum sum of the k picked coins' values, denoted by f(k).
Furthermore, we want to know f(1),f(2),⋯,f(2n).