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