Awkward Auction

면접 대비

시간 제한1초메모리 제한1024 MB

요약
1부터 n 사이의 비밀 가격을 맞히는 게임에서, 낮게 부르면 뇌물 b를 내고 같거나 높게 부르면 그 가격에 사야 할 때 최악의 경우 최소 비용을 구한다.
난이도

보통10점 중 7점

유형
동적 계획법, 이분 탐색, 게임 이론
정답자
아직 제출이 없습니다

문제

Your local warehouse's marketing department has thought of a new way of extracting money from their consumers: organizing the Battle in Assessing Precisely Costs (BAPC).

A battle is played against an auctioneer. The auctioneer has an unlimited number of identical gems available, which all have the same fixed secret worth. This secret worth is an integer between 1 and nn (inclusive, in euros). In each round, you have to bid an integer amount of euros on such a gem, and your goal is to bid exactly the secret worth. If you bid at least the secret worth, you have to buy the gem for the amount of your bid. On the other hand, if you bid less than the secret worth, you do not get the gem and keep your bid. However, if you bid less than the worth, the auctioneer will give an endless speech why the gem is clearly worth more than the bid. To stop this speech and be able to make a new bid, you have to bribe the auctioneer with bb euros each time. Finally, if you bid exactly the secret worth, then in addition to buying the gem, you get a nice cup showing that you won the battle, and the battle immediately ends.

Since the BAPC is your favourite competition, you of course want this cup! Therefore, you keep bidding until you bid the right amount and get the cup. You wonder how much this will cost you in the worst case, assuming that you make optimal decisions for the amounts to bid.

입력

The input consists of:

  • One line with two integers nn and bb (1≤n≤4001 \leq n \leq 400, 1≤b≤10,0001 \leq b \leq 10\\,000), the given maximum worth of the gem and the bribe you need to pay when bidding too low.

출력

Output the maximum cost in euros that you have to pay in the worst case if you bid optimally.

예제2

  1. 예제 1

    입력
    4 2
    
    예상 출력
    6
    
  2. 예제 2

    입력
    8 3
    
    예상 출력
    16