## Editorial for Wesley's Anger Contest 4 Problem 2 - Squirrel Election

Remember to use this editorial

**only**when stuck, and**not to copy-paste code from it**. Please be respectful to the problem author and editorialist.**Submitting an official solution before solving the problem yourself is a bannable offence.**Author:

##### Subtask 1

Since the number of votes needed to take any province is always the same, it's always optimal to take the provinces with greatest number of points.

Thus, a greedy solution suffices for this subtask.

**Time Complexity:**

##### Subtask 2

Let

Let

Let be the minimum cost needed to secure points using the first provinces. can be defined recursively as with a base case of .

The final answer is simply .

**Time Complexity:**

Another similar problem: Knapsack 2

It is also possible to blackbox the knapsack algorithm used in Knapsack 1 by having the value of the items be equal to and the weight of the items equal . The answer in this case is equal to

## Comments