tacodepastor's blog

By tacodepastor, 10 years ago, In English

Hello all. I am currently having trouble understanding the DP approach to solving problem 452D. I have read a few of the solutions but I fail to understand why they work.

Thanks in advance. :)

  • Vote: I like it
  • +14
  • Vote: I do not like it

»
10 years ago, # |
  Vote: I like it -61 Vote: I do not like it

nobody cares

  • »
    »
    10 years ago, # ^ |
      Vote: I like it +37 Vote: I do not like it

    Wow, what an asshole, Bredor. Taco, I really hope you aren't put off of the entire community because of people like him. Personally, I didn't actually use a DP, I went with a greedy. Would you like me to explain that one or are you going for the DP specifically? BTW, as a fellow fan of tacos al pastor, nice username. :)

»
10 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Well the idea is quite simple, since k = 10^4 and there are only 3 thing to do you can simulate all the process, you just need to store the time where each laundry piece is ready w[] and the time where each machine is ready time_m[]. At the beginning each w[] and time_w[] will be 0, Now for each process wash,dry,fold (lets index with j) the time where the i-th piece of laundry is ready is after the piece is ready or the machine that will serve this piece (which is i%n[j]) is ready plus the time to be served, I mean w[i] = time_m[i%n[j]] = max(time_m[i%n[j]],w[i])+t[j]. Finally the answer is the max element of w, which is w[k]. Hope I have explained it clearly. my submission during contest