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

Автор yesnomaybe, история, 4 года назад, По-английски

Hi,

Can someone please help me with the following problem? https://atcoder.jp/contests/abc155/tasks/abc155_e

I found this dp solution, am unable to understand what does dp state denote and how transitions are made? https://atcoder.jp/contests/abc155/submissions/10154214

Or any other solution?

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

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

    Hi, thanks for the reply. I did check out that comment but I am unable to understand it. Can you please elaborate a bit on what does dp state denote (as in what does carry mean?).

    Can you please shed more light on the solution?

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

      As in what's the intuition/logic behind it? What are we trying to do exactly?

      • »
        »
        »
        »
        4 года назад, # ^ |
          Проголосовать: нравится +1 Проголосовать: не нравится

        Start considering from the least significant position. Here either you can choose to pay that position's value or increase the amount so that the clerk returns the number of notes for that position as (10-that value) with your next higher significant payment increased by one (i.e you are paying on more note for the next higher position and expecting the desired return for this position).

        This happens for every digit from right to left and we have the options of giving the value or expecting a change by giving some extra money.

        Finally, at the most significant position, you come to know whether at each digit you ask for change there or give the amount in case you want to know the number of notes of each type which is not required though.