[Noip 2014 review] Chapter 2: Dynamic Planning -- Review of previous problems of noip

Source: Internet
Author: User
Sequential Dynamic Planning 1. wikioi 1058

DescriptionDescription

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 meets t1 <... <Ti> Ti + 1>...> TK (1 <= I <= K ).

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.

Input description Input description

The first line of the input file chorus. In is an integer N (2 <= n <= 100), indicating the total number of students. The first line contains N integers separated by spaces. the I-th integer Ti (130 <= Ti <= 230) is the height (cm) of the I-th student ).

Output description Output description

The output file chorus. Out contains a row. This row contains only one integer, that is, at least a few students are required to columns.

Sample Input Sample Input

8
186 186 150 200 160 130 197

Sample output Sample output

4

Data range and prompt Data size & hint

For 50% of the data, there must be n <= 20;
For all data, ensure that N is less than or equal to 100.

This question can be done using the longest ascending subsequence and the longest descending subsequence, but some details need to be processed,

# Include <stdio. h> # include <stdlib. h> # include <string. h> # define maxn 300int high [maxn]; // high [I] = int up [maxn], DN [maxn]; int max (int A, int B) {If (A> B) return a; return B;} int main () {int N; scanf ("% d ", & N); For (INT I = 1; I <= N; I ++) {scanf ("% d", & high [I]); up [I] = DN [I] = 1 ;}for (INT I = 1; I <= N; I ++) for (Int J = 1; j <= I; j ++) if (high [J] 




Zookeeper

[Noip 2014 review] Chapter 2: Dynamic Planning -- Review of previous problems of noip

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.