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
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的更多相关文章

  1. Codeforces 1029B. Creating the Contest 动态规划O(nlogn)解法 及 单调队列O(n)解法

    题目链接:http://codeforces.com/problemset/problem/1029/B 题目大意:从数组a中选出一些数组成数组b,要求 b[i+1]<=b[i]*2 . 一开始 ...

  2. Codeforces Round #506 (Div. 3)B.Creating the Contest(dp)

    B. Creating the Contest time limit per test 1 second memory limit per test 256 megabytes input stand ...

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

    B. Creating the Contest time limit per test 1 second memory limit per test 256 megabytes input stand ...

  4. CodeForces 377B---Preparing for the Contest(二分+贪心)

    C - Preparing for the Contest Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d ...

  5. codeforces B. Valera and Contest 解题报告

    题目链接:http://codeforces.com/problemset/problem/369/B 题目意思:给出6个整数, n, k, l, r, sall, sk ,需要找出一个满足下列条件的 ...

  6. Codeforces 140D - New Year Contest

    140D - New Year Contest 思路:贪心+排序.罚时与时间成正比,因为在0点前做完的题都可以在0点提交.从时间短的开始做最优. 代码: #include<bits/stdc++ ...

  7. codeforces 659B B. Qualifying Contest(水题+sort)

    题目链接: B. Qualifying Contest time limit per test 1 second memory limit per test 256 megabytes input s ...

  8. CodeForces - 681A A Good Contest

    咳咳,从今天开始,每天做一个英语题,不论简单还是难,坚持到下学期的省赛,希望能有效果. 这题就是判断是否能成为red,如果他超越的人里面有在比赛前分数达到2400,并且在比赛后分数上升,那么他就能成为 ...

  9. B. Creating the Contest(水题)

    直接水过 #include<iostream> #include<algorithm> using namespace std; ; int a[maxn]; int n, u ...

随机推荐

  1. scrapy install

    csf@ubuntu:~$ sudo apt install python-scrapy

  2. Java中的return this

    return this就是返回当前对象的引用(就是实际调用这个方法的实例化对象) 示例: /** * 资源url */ public HttpConfig url(String url) { urls ...

  3. vue中登录模块的插件封装

    一个电商城的项目,场景是:在未登录的情况下点击收藏或者加入购物车等操作,执行一个方法如this.$login()来动态插入登录组件. 第一步:写好关于这个登录弹窗的单文件组件 loginBox.vue ...

  4. vue面试常被问到的问题整理

    1.Vue的双向数据绑定原理是什么? 答 : vue是采用数据劫持,并且使用发布-订阅者的开发模式.原理是观察者observer通过Object.defineProperty()来劫持到各个属性的ge ...

  5. DNS的主从,转发与负载功能

    接着原来<DNS原理与应用>的文章,本章内容主要通过实现DNS的主从,转发,及基于域名解析不同的ip实现后端服务负载均衡的效果.最后再实现DNS的高级功能:类似CDN原理实现基于IP实现区 ...

  6. django+xadmin在线教育平台(九)

    django admin介绍 上一章我们进行了需求分析和数据库设计.本章我们来快速搭建一个可用的后台管理系统. 后台管理系统特点: 权限管理 少前端样式.(样式一般不是很看重), 快速开发 djang ...

  7. scrapy--多爬虫

    大家好,我胡汉三又回来了!!!开心QAQ 由于最近一直在忙工作的事,之前学的一些爬虫知识忘得差不多了,只能再花多一些时间来回顾,否则根本无法前进.所以在这里也像高中老师那样提醒一下大家,--每天晚上花 ...

  8. Python变量、赋值及作用域

    ## 变量 - 指向唯一内存地址的一个名字 - 目的是为了更方便地引用内存中的值 - 可以使用id(变量)函数来查看变量的唯一id值,若两者id值相同,则表示两个变量指向同一地址,两个变量的值完全相同 ...

  9. java中substring()、charAt()、indexOf() (2013-05-05-bd 写的日志迁移

    substring 1. public String substring(int beginIndex)     返回一个新的字符串,它是此字符串的一个子字符串, 该子字符串始于指定索引处的字符,一直 ...

  10. flask-login原理详解

    最近发现项目中使用的flask-login中有些bug,直接使用官网的方式确实可以用,但仅仅是可以用,对于原理或解决问题没有什么帮助,最近通过查看网上资料.分析源码.通过demo.从零开始总结了fla ...