CodeForces B. Creating the Contest

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+1≤aij?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 (1≤n≤2?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 (1≤ai≤1091≤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

101 2 5 6 7 10 21 23 24 49

output

Copy

4

input

Copy

52 10 50 110 250

output

Copy

1

input

Copy

64 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;
}

  

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

时间: 2024-11-09 15:17:18

CodeForces B. Creating the Contest的相关文章

codeforce1029B B. Creating the Contest(简单dp,简单版单调栈)

B. Creating the Contest time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a problemset consisting of nn problems. The difficulty of the ii-th problem is aiai. It is guaranteed t

【Codeforces:从头开始】contest 1

[Codeforces:从头开始]contest 1      1A      用 a × a 的石板覆盖 n × m 的长方形广场,允许石板覆盖的区域超出广场,不允许打破石板,石板的两侧应平行于广场两侧,要求覆盖完广场所需的石板数量最少是多少 样例图示: (显然,答案为每边必须铺的+铺出去(1个或0个)) 注意开 long long 代码: #include<bits/stdc++.h> using namespace std; typedef long double ld; typedef

codeforce B. Creating the Contest

http://codeforces.com/contest/1029/problem/B 水题真快乐= = 1 public class Main { 2 public static void main(String[] args) { 3 Scanner io = new Scanner(System.in); 4 long n = io.nextInt() - 1, a = io.nextInt(), b, len = 1, ans = 1; 5 for (int i = 1; i <= n

CodeForces 659 B. Qualifying Contest(结构体排序的问题)

传送门 B. Qualifying Contest time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Very soon Berland will hold a School Team Programming Olympiad. From each of the m Berland regions a team of two people

【贪心/DP/单调队列】【CF1029B】Creating the Contest

Description 给你一个单调不下降的长度为n的序列,请你找出一个最长的子序列,满足找出的子序列中,\(A_i<=A_{i-1}~\times~2\),其中i为下标,A为找出的子序列.对于一个长度为\(p\)的子序列,\(i~\in~[1,p-1]\). Input 两行,第一行是原序列的长度\(n\) 第二行是\(n\)个数,代表原序列中的\(n\)个数. Output 一行一个数,代表最长的长度 Sample Input 10 1 2 5 6 7 10 21 23 24 49 Samp

B. Creating the Contest(水题)

直接水过 #include<iostream> #include<algorithm> using namespace std; const int maxn=2e5+10; int a[maxn]; int n, u,maxx; int main(){ cin>>n; u=1; for(int i=0;i<n;++i)cin>>a[i]; for(int i=0;i<n-1;++i){ if(a[i]*2>=a[i+1]){ ++u; }

Codeforces Round #506 (Div. 3) 题解

Codeforces Round #506 (Div. 3) 题目总链接:https://codeforces.com/contest/1029 A. Many Equal Substrings 题意: 给出长度为n的字符串,然后要求你添加一些字符,使得有k个这样的字符串. 题解: 直接暴力吧...一个指针从1开始,另一个从2开始,逐一比较看是否相同:如果不同,第一个指针继续回到1,第二个指针从3开始...就这么一直重复.最后如果第二个指针能够顺利到最后一位,那么记录当前的第一个指针,把他后面的

Codeforces Round #486 (Div. 3) C. Equal Sums

Codeforces Round #486 (Div. 3) C. Equal Sums 题目连接: http://codeforces.com/group/T0ITBvoeEx/contest/988/problem/C Description You are given k sequences of integers. The length of the i-th sequence equals to ni. You have to choose exactly two sequences

Codeforces Round #486 (Div. 3) D. Points and Powers of Two

Codeforces Round #486 (Div. 3) D. Points and Powers of Two 题目连接: http://codeforces.com/group/T0ITBvoeEx/contest/988/problem/D Description There are n distinct points on a coordinate line, the coordinate of i-th point equals to xi. Choose a subset of