Description [title]
A country in order to defend against enemy missile attacks, the development of a missile interception system, but the interceptor system has a flaw: Although it's the first rounds to reach any height, but each shell and should not be higher than the previous hair height . One day, the radar picked up incoming enemy missiles, because the system is still in beta. Therefore, a system may not intercept all the missiles.
Sequentially input missile flying height (the height of the radar gives a positive integer no greater than 30,000). To calculate the intercept all missiles minimum required number of sets of such a missile interception system is equipped.
[Enter]
n pieces sequentially flying height (1≤n≤1000).
[Output]
To block all equipped with the smallest number of missile systems k.
[Sample input]
389 207 155 300 299 170 158 65
[Sample Output]
2
【prompt】
Input: Missile Height: 432
Output: k = 1 missile interceptors
// Created on 2020/2/12
/*#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <climits>*/
#include <bits/stdc++.h>
using namespace std;
const int idata=1000+5;
int goal[idata];
int step[idata];
int n,m;
int flag;
int cnt;
int ans=1;
int maxx=0;
int main()
{
int i,j;
while(scanf("%d",&n)!=EOF)
goal[cnt++]=n;
step[1]=goal[0];
for(i=1;i<cnt;i++)
{
flag=0;
maxx=0;
for(j=1;j<=ans;j++)
{
if(!flag)
{
if(step[j]>=goal[i])//不高于前一发,所以“大于等于”
{
flag=j;
maxx=step[j];
}
}
if(flag)
{
if(maxx>step[j])
{
flag=j;
maxx=step[j];
}
}
}
if(flag)
step[flag]=goal[i];
if(!flag)
step[++ans]=goal[i];
}
cout<<ans<<endl;
/*for(i=1;i<=ans;i++)
{
cout<<step[i]<<endl;
}*/
}