时间限制: 1 Sec 内存限制: 64 MB
题目描述
Redraiment是个聪明人,总是以奇怪的思考方法思考问题,但不知道为什么,他的解答总是最最巧妙,我们隆重地称他为诡异人! 有一天Jesse不经意中发现,诡异人的走路方法很特别,于是特别关注了他的走路规则。他发现诡异人总是往高处走,但走的步数总是最多,不知道为什么?你能替Jesse研究研究他最多走的步数吗? 发现了你也会是个聪明人!^_^
输入
There has several test cases. Each case start with an integer n(0 < n ≤10000), then follows n lines.Each line has an integer h( 1 ≤ h ≤ 100),which represents the height of the place.
输出
For each case output a line with the max number of the steps he can go .
样例输入
51 2 3 4 562 5 1 5 4 5
样例输出
53
提示
Example:
6个点的高度各为 2 5 1 5 4 5
如从第1格开始走,最多为3步, 2 4 5
从第2格开始走,最多只有1步,5
而从第3格开始走最多有3步,1 4 5
从第5格开始走最多有2步,4 5
来源
只会走一个方向的诡异人。
#include <bits/stdc++.h>
#define int long long
#define cl(arr) memset(arr,0,sizeof arr)
using namespace std;
const int N=10010;
int n;
int a[N],dp[N];
int ans;
void solve()
{
while(cin>>n){
ans=1;
for(int i=1;i<=n;i++){
dp[i]=1;
cin>>a[i];
for(int j=1;j<i;j++){
if(a[i]>a[j]) dp[i]=max(dp[j]+1,dp[i]);
}
ans=max(ans,dp[i]);
}
cout<<ans<<"\n";
}
return;
}
signed main()
{
// ios::sync_with_stdio(0);
// cin.tie(0);cout.tie(0);
int t;
// cin>>t;
t=1;
while(t--)
solve();
return 0;
}
/*
*/