1052: Redraiment的走法

时间限制: 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

来源

Jesse

只会走一个方向的诡异人。

#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;
}
/*

*/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值