码迷,mamicode.com
首页 > 其他好文 > 详细

CodeForces B. Creating the Contest

时间:2018-10-20 21:04:15      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:www.   tis   \n   int   eating   blank   printf   contest   sele   

http://codeforces.com/contest/1029/problem/B

 

You are given a problemset consisting of nn problems. The difficulty of the ii-th problem is aiai. It is guaranteed that all difficulties are distinct and are given in the increasing order.

You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let ai1,ai2,,aipai1,ai2,…,aip be the difficulties of the selected problems in increasing order. Then for each jj from 11 to p?1p?1 aij+1aij?2aij+1≤aij?2 should hold. It means that the contest consisting of only one problem is always valid.

Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.

Input

The first line of the input contains one integer nn (1n2?1051≤n≤2?105) — the number of problems in the problemset.

The second line of the input contains nn integers a1,a2,,ana1,a2,…,an (1ai1091≤ai≤109) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.

Output

Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.

Examples
input
Copy
10
1 2 5 6 7 10 21 23 24 49
output
Copy
4
input
Copy
5
2 10 50 110 250
output
Copy
1
input
Copy
6
4 7 12 100 150 199
output
Copy
3

代码:

#include <bits/stdc++.h>
using namespace std;

const int maxn = 200010;
int N;
int num[maxn];

int main() {
    scanf("%d", &N);
    scanf("%d", &num[1]);
    int a = num[1];
    int ans = 0;
    int temp = 1;
    for(int i = 2; i <= N; i ++) {
        scanf("%d", &num[i]);
        if(2 * a >= num[i]) {
            ans = max(ans, i - temp);
        }
        else
            temp = i;
        a = num[i];
    }
    printf("%d\n", ans + 1);
    return 0;
}

  

CodeForces B. Creating the Contest

标签:www.   tis   \n   int   eating   blank   printf   contest   sele   

原文地址:https://www.cnblogs.com/zlrrrr/p/9822798.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!