#include <bits/stdc++.h>
using namespace std;
map<int,int> mp;
map<int,int>::iterator it;
int a[50050];
int main()
{
int n,i,ans;
while(cin>>n)
{
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
ans=0;
mp.clear();
for(i=n;i>=1;i--)
{
it=mp.lower_bound(a[i]);
if(it==mp.end())
mp[a[i]]=i;
else
ans=max(ans,(it->second)-i);
}
printf("%d\n",ans);
}
}
51nod 1272 最大距离
最新推荐文章于 2019-11-22 22:00:23 发布