2015 Huawei test-teams, 2015 Huawei test team
Description:
Calculate the minimum number of students listed, so that the remaining students are lined up
Note:
N students stood in a row, and the music teacher asked the (N-K) students to make the remaining K students lined up.
A queue is a formation in which K students are numbered 1, 2, and so on from left to right ..., K. Their heights are T1, T2 ,..., TK, then their height is satisfied with I (1 <= I <= K) so that Ti <T2 <...... <Ti-1 <Ti> Ti + 1>...> TK.
Your task is to know the height of all N students. The calculation requires at least a few students to make the remaining students form a queue.
Category: Cycle
Difficulty: elementary
Running time limit: Unlimited
Memory limit: Unlimited
Stage: Pre-Employment exercises
Input:
Integer N
A line of integers separated by spaces. Height of N students
Output:
At least a few students are required
Sample input:
8
186 186 150 200 160 130 197
Sample output:
4
The Code is as follows:
Public class he_ChangDui {public static void main (String [] args) {consumer SC = new consumer (System. in); // n indicates the number of people. int n = SC. nextInt (); int [] height = new int [n]; for (int I = 0; I <n; I ++) {height [I] = SC. nextInt ();} int [] temp = new int [n]; for (int I = 0; I <n; I ++) {int [] a = new int [I]; for (int j = 0; j <I; j ++) {a [j] = height [j];} int [] B = new int [height. length-I]; for (int k = I; k
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.