2015 Huawei test-teams, 2015 Huawei test team

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.