The Uncertainty of Politics

From programming_contest
Jump to navigation Jump to search
  1. Order meetings 1->N by start time
  2. solution is expected value of 1, or E(1)
  3. E(n) calculated as max of
    1. E(n+1) meaning we didn't attend this meeting
    2. 1 + sum (E(n+x) * p(x)) where p(x) is the probability of x being the first meeting we can go to after this meeting ends
  4. memoize

memoization array is 10^4 big, and at max, iterate over 10^4 future meetings....so 10^8 is fast enough. Note that 10^4 is a pretty good hint the runtime is parabolic-ish.

Can easily flip problem to DP by starting with the last meeting, which has E=1, since you always attend it if you can.