9. You\'re helping to run a high-performance computing system capable of process
ID: 3860432 • Letter: 9
Question
9. You're helping to run a high-performance computing system capable of processing several terabytes of data per day. For each of n days, you're presented with a quantity of data; on day i, you're presented with x terabytes. For each terabyte you process, you receive a fixed revenue, but any unprocessed data becomes unavailable at the end of the day (i.e, you can't work on it in any future day). You can't always process everything each day because you're con- strained by the capabilities of your computing system, which can only process a fixed number of terabytes in a given day. In fact, it's running some one-of-a-kind software that, while very sophisticated, is no reliable, and so the amount of data you can process goes down with each day that passes since the most recent reboot of the system. On the first day after a reboot, you can process s, terabytes, on the second day after a reboot, you can process s2 terabytes, and so on, up to sn we assume si > s2 > s? … > sn > 0. (Of course, on day i you can only process up to xi terabytes, regardless of how fast your system is.) To get the system back to peak performance, you can choose to reboot it; but on any day you choose to reboot the system, you can't process any data at all. The problem. Given the amounts of available data X1,X2, -. . , xn for the next n days, and given the profile of your system as expressed by s1.s2,. .. ,Sn (and starting froma freshly rebooted systemonday 1), chooseExplanation / Answer
def test(list, func): v = [0]*(len(list)+2) f_ = 0 for j in range(len(func)): v[j] = max(v[j-2] + min(func[0],list[j]), v[j-1]+min(list[j], func[f_])) if v[j] == v[j-2] + min(func[0],list[j]): f_ = 0 #print "func[f_]:", func[f_], v[j-2], min(func[0],list[j]), v[j-1] + min(list[j], func[f_]) f_ += 1 print "max:", v[len(list)-1], v[:len(list)] if __name__ == "__main__": test([10,10,10,10,10], [1,1,1,1,1]) test([10,10,10,10,10], [9,4,3,2,1]) test([0,10,10,10,10], [9,4,3,2,1]) test([0,0,10,10,10], [9,4,3,2,1]) test([10,0,10,0,10], [9,4,3,2,1]) test([10,1,7,7], [8,4,2,1]) test([10,0,10,500,10], [500,4,3,2,1])
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.