// Which floor does the elevator stop on? Can the minimum number of floors of all passengers who climb the stairs of the elevator be reached? Public class test_005 {// person [I] indicates the number of people to reach the I-level. person [0], person [1] is blank by default, that is, no one goes to layer 1 static int [] person = {0, 0, 5, 7, 8, 9, 6, 6, 1, 4, 4, 8, 5, 2, 4, 5, 8, 6, 3, 3, 5, 9, 9, 6, 6, 9, 8, 5, 5, 9, 6, 6, 3}; static int stopfloor = 0; // number of floors stopped by the elevator static int sumfloor = 0; // total number of floors crawled by a passenger static int n = person. length-1; // total number of floors static int n1 = 0; // number of people leaving the elevator to stay under the floor static int n2 = 0; // The number of people who leave the elevator to stay on the floor. Static int N3 = 0; // Number of people who leave the elevator on the floor/*** calculate the target floor * @ Param person // record the number of people to reach each floor */public static void targetfloor (INT [] person) {// if there is no more than 1 floor, you do not need to take the elevator. If (null = person | person. length <= 2) {return ;}// when the elevator stays on the second floor, stopfloor = 2; n1 = 0; N2 = person [stopfloor]; for (INT I = 3; I <= N; I ++) {N3 + = person [I]; sumfloor + = person [I] * (I-stopfloor );} // when the elevator stays above Layer 3, for (INT I = 3; I <= N; I ++) {If (N1 + N2 <N3) {stopfloor = I; n1 = N1 + N2; N2 = person [I]; N3 = N3-person [I]; sumfloor + = N1 + N2-N3 ;}}} public static void main (string [] ARGs) {targetfloor (person); system. out. println ("staying at:" + stopfloor + "Total number of passenger floors:" + sumfloor );}}