博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
codeforce1029B B. Creating the Contest(简单dp,简单版单调栈)
阅读量:4586 次
发布时间:2019-06-09

本文共 2394 字,大约阅读时间需要 7 分钟。

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 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 p1p−1 aij+1aij2aij+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 (1n21051≤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
Note

Description of the first example: there are 1010 valid contests consisting of 11 problem, 1010 valid contests consisting of 22 problems ([1,2],[5,6],[5,7],[5,10],[6,7],[6,10],[7,10],[21,23],[21,24],[23,24][1,2],[5,6],[5,7],[5,10],[6,7],[6,10],[7,10],[21,23],[21,24],[23,24]), 55 valid contests consisting of 33 problems ([5,6,7],[5,6,10],[5,7,10],[6,7,10],[21,23,24][5,6,7],[5,6,10],[5,7,10],[6,7,10],[21,23,24]) and a single valid contest consisting of 44 problems (

转载于:https://www.cnblogs.com/caiyishuai/p/9548080.html

你可能感兴趣的文章
IaaS,PaaS,SaaS 的区别
查看>>
Python复习基础篇
查看>>
关于Cocos2d-x中背景音乐和音效的添加
查看>>
.Net持续集成 —— Jenkins+Git+WebDeploy
查看>>
01_Numpy基本使用
查看>>
吴裕雄--天生自然 R语言开发学习:使用键盘、带分隔符的文本文件输入数据
查看>>
CSS选择器详解
查看>>
checkbox和文字对齐
查看>>
JConsole远程连接配置 服务器监控工具
查看>>
了解HTTP协议栈(实践篇)
查看>>
loj10035. 「一本通 2.1 练习 1」Power Strings
查看>>
%s的用法
查看>>
调用底层不能直接访问的类和方法
查看>>
清理缓存的方法 #DF
查看>>
JAVA array,map 转 json 字符串
查看>>
APICloud模块 aMapLBS.singleAddress在ios返回的是定位而不是地址
查看>>
【ZOJ】1610 Count the Colors
查看>>
抱歉最近朋友结婚去浪了几天~未来几天会正常更新.今天带来XML文件解析
查看>>
[beta cycle]daily scrum7_2.22
查看>>
BSD历史
查看>>