Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя User_NULL

Автор User_NULL, история, 18 месяцев назад, По-английски

Is there any greedy approach for finding minimum operations required for making a_i to b_i ?

https://codeforces.me/contest/1633/problem/D

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
18 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

This is weird! I think this is because we can know how many operations are needed to get from $$$1$$$ to $$$b_i$$$ greedily.

  • »
    »
    18 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    can you share your greedy approach ?

    i've been trying but not able to come up with any!!

    • »
      »
      »
      18 месяцев назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      We can always choose $$$x = 1$$$ so that when performing $$$a_i = a_i + \lfloor{\frac{a_i}x\rfloor}$$$ is the same as $$$ a_i = 2a_i$$$.

      Let $$$b_i$$$ is the minimum number of the above operation to get from $$$1$$$ to $$$i$$$. Sense $$$i <= 10^3$$$ so we need at most $$$\lceil \log_2{10^3} \rceil$$$ operations, $$$b_i \le 10$$$.


      Update:

      Ops! forget about it, in the last operation we can't increase by all values in the range $$$[1, a_i)$$$. Only some of them are available.

      The editorial provided a DP approach for it, check it out.

»
18 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

It tagged greedy because it's a knapsack problem.

By the way, thanks for sharing a great problem to solve.

  • »
    »
    18 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    But the problem can't be solved greedily. The greedy approach only works with the fractional knapsack (as far as I know).

»
18 месяцев назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Tags are sometimes wrong.