All problems

Problem 961

Guess Number Higher or Lower II

Medium · 20 pts · Math, Dynamic Programming, Game Theory

Problem

A secret number is between 1 and N. Each time you guess a wrong number x, you pay x and are told whether the secret is higher or lower. Find the smallest amount of money that guarantees you can find the secret whatever it is (the cost of the final correct guess is free). Let cost(lo, hi) be the answer for a range: try every first guess x and take max(cost(lo, x - 1), cost(x + 1, hi)) + x, choosing the cheapest x.

Input

A single integer N.

Output

Print the minimum money needed to guarantee a win.

Constraints

1 <= N <= 200

Example input

10

Example output

16

Explanation

For N = 2, guess 1 first: if it is wrong you pay 1 and the answer must be 2. So 1 is enough. For N = 10 the answer is 16.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Minimum Score Triangulation of Polygon Next: Stone Game III