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

Автор MciprianM, 14 лет назад, По-английски
At ACM ICPC SEERC 2009 was this problem:
   Problem E.
I need a hint to solve it. My instinct tells me that some sort of dynamic programming would do. But I can't figure it out.
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

14 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
Maybe it can be solved by the following way:
States of the DP is a(i, j), where a(i,j) = minimum makespan when first application consists of procedures (1,i)(1,i+1)..(1, N), and second application consist of procedures (2,j).(2,j+1),...,(2,N). Thus there are O(n^2) DP states.
   Now if we need to calculate a(i,j) then we try to go on both application i.e. execute corresponding procedures
until first collision happens. In this case there are some r and k that P(1,r)=P(2,k). Consider two possibilities - procudere (1,r) are waiting and procedure (2, k) are executing, and vice versa. So a(i,j) = min(T2 + a(r, k +1),
T1 + a(r + 1, k), where T1 is time first application to executes procedures (i,..., r), and T2 is time second application to executes procedures (j,..., k). Thus overall time complexity is O(N^3).
14 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится
The idea suggested by MBabin (check the comments in Russian) looks correct: let d[i][j] be the time needed to finish the last i procedures of application 1 and the last j procedures of application 2. The transition is O(N) with two pointers: suppose you have chosen to run application 1 first. Then you either wait until its procedure finishes or run application 2 simultaneously.
However, the time limit is tough and some optimizations are needed.
Here is the code that got accepted on this online judge.
14 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
Oau!! Thanks a lot! I learnt lots of things from your comment. I didn't know this problems were on an online judge(I've got solutions for the first four, now all I need is to send it). This will save me a lot of time. Also I didn't know I have to check both codeforces sites(.com and .ru) so I didn't see MBabin's comment. Also last night I thought of a solution so I will try to implement it before I read your solutions. Thanks a lot. You speak romanian don't you. (Sad girls?)