题解 CF580A 【Kefa and First Steps】

2018-04-04 23:43:11


Vector数组加迭代器,有点麻烦

#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
using namespace std;

const int MAXN(10086);
vector <int> v; //建一个Vector动态数组

int main(){
    ios::sync_with_stdio(false);
    int tmp,n,ans=0,cnt=0;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>tmp;
        v.push_back(tmp); //存入数据
    }
    for(vector <int>::iterator it = v.begin()+1;it!=v.end();++it){
        vector <int>::iterator tmp2=it-1; //迭代器指向前一个元素
        if((*it)>=(*tmp2)){
            cnt++;
            ans=max(cnt,ans);
        } else cnt=0;
    }
    cout<<ans+1;
    return 0;
}