codeforces 1029 B - Creating the Contest

题目描述:http://codeforces.com/contest/1029/problem/B
这个题因为给出的序列已经排过序了,所以答案是连续的
c++代码:

#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <vector>
using namespace std;

typedef long long LL;

const int maxn=1e5*2+2;
LL len,a[maxn];
vector <int> v;
int main(){
    LL n;
    scanf("%lld",&n);
    LL cnt=0;
    scanf("%lld",&a[0]);
    v.push_back(a[0]);
    int ans=0;
    if(n>1) {
        for(int i=1;i<n;i++){
     scanf("%lld",&a[i]);

        if(v[v.size()-1]*2>=a[i])v.push_back(a[i]);
     if(ans<v.size())ans=v.size();
     if(v[v.size()-1]*2<a[i]){v.clear();v.push_back(a[i]);}

    }
    cout << ans <<endl;
    }
    else cout << 1 <<endl;

    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_39475280/article/details/82049472