Let n (2<=n<=33) be the floor that the elevator stopped, D(n) be the total displeased points. Since everyone tried to minimize his displease points, people live at or lower than floor [(n+3)/4] (here, [x] is the largest integer less than or equal to x) will walk, all others will take the elevator. If n+3 = 0 (mod 4), the person lives at floor (n+3)/4 is indifferent, so we assume he/she will always take the elevator. www.ddhw.com Consider D(n+1)-D(n) (2<=n<=32), then we only have to consider those taking the elevator. Let the total displease points for those walking be S. D(n+1) = 3(1+…+(33-n-1))+(1+…+(n+1-[(n+3)/4])) + Swww.ddhw.com D(n) = 3(1+…+(33-n))+(1+…+(n-[(n+3)/4])) + S So D(n+1)-D(n) = (n+1-[(n+3)/4])-3(33-n) = 4n-98-[(n+3)/4] It’s negative when n < 27, positive when n >= 27.www.ddhw.com That means floor 27 is the best choice. The total displease points are 3(1+…+6)+(1+…+19)+3(1+…+5) = 63 + 190 + 45 = 298. www.ddhw.com
|