Test instructions
n plates, each plate has weight and strength W and s, and PDV value (total weight above-the strength of the board) for some sort of stacking mode, the maximum value of PDV is the minimum value for which it represents the value to consider only two plates of the case: A and B, it is obvious that the following is more prone to damage than the above, so the following Suppose A is above, its PDV value = Pdvb = Wa-sb. Suppose B is above, its PDV value = Pdva = Wb-sa. The two values are then minimized, if a is small on the PDV, then WA-SB < Wb-sa, i.e. WA + SA < WB + sb. Similarly, if B is small on the PDV, WB + SB < WA + SA. Expansion to the case of N boards, any two adjacent plates do not affect the other board, so according to W+s from small to large, from top to bottom.
Try: while True: n = input (); n = int (n); a = []; For I in range (0, N): str = input (). split (); A + = [[Int (str[0]), int (str[1])]; A = sorted (A, key = Lambda x:x[0]+x[1]); SUMV = 0; Maxx = 0; For I in range (0, N): maxx = Max (Maxx, Sumv-a[i][1]); SUMV + = a[i][0]; Print (Maxx); except Eoferror: Pass
"Python3" "greedy" hdu4296 buildings