CF1029B.Creating the Contest
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a problemset consisting of n problems. The difficulty of the i-th problem is ai. 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,…,aip be the difficulties of the selected problems in increasing order. Then for each j from 1 to p−1 aij+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.
你被给定一个包含 n 道题的问题集。第 i 道题的难度为 ai。保证所有难度值互不相同,且按升序给出。
你需要从该问题集中选出若干题目来组成一场竞赛。换言之,这场竞赛必须是原问题集的一个子集(子集中的题目在原问题集中不必连续)。仅需满足如下唯一条件:对于除最难题目(即难度最大的那道题)外的每一道题,都必须存在另一道题,其难度严格大于该题的难度,但不超过该题难度的两倍。换句话说,设所选题目的难度按升序排列为 ai1,ai2,…,aip,则对每个 j=1,2,…,p−1,均需满足 aij+1≤aij⋅2。这意味着仅含一道题的竞赛总是合法的。
在所有满足上述条件的竞赛中,你需要构造出题目数量最多的一个。你的任务是求出这个最大题目数量。
输入格式
The first line of the input contains one integer n (1≤n≤2⋅105) — the number of problems in the problemset.
The second line of the input contains n integers a1,a2,…,an (1≤ai≤109) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
输入的第一行包含一个整数 n(1≤n≤2⋅105)—— 表示题集中的题目数量。
输入的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109)—— 表示各题目的难度。保证所有题目的难度互不相同,且按升序给出。
输出格式
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
输出一个整数——满足题目条件的竞赛中问题数量的最大值。
输入输出样例
输入#1
10 1 2 5 6 7 10 21 23 24 49
输出#1
4
输入#2
5 2 10 50 110 250
输出#2
1
输入#3
6 4 7 12 100 150 199
输出#3
3
说明/提示
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1,2],[5,6],[5,7],[5,10],[6,7],[6,10],[7,10],[21,23],[21,24],[23,24]), 5 valid contests consisting of 3 problems ([5,6,7],[5,6,10],[5,7,10],[6,7,10],[21,23,24]) and a single valid contest consisting of 4 problems ([5,6,7,10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4,7,12] and [100,150,199].
第一个样例的说明:包含 1 道题的有效比赛共有 10 场,包含 2 道题的有效比赛共有 10 场(即 [1,2],[5,6],[5,7],[5,10],[6,7],[6,10],[7,10],[21,23],[21,24],[23,24]),包含 3 道题的有效比赛共有 5 场(即 [5,6,7],[5,6,10],[5,7,10],[6,7,10],[21,23,24]),以及唯一一场包含 4 道题的有效比赛(即 [5,6,7,10])。
第二个样例中,所有有效比赛均只包含 1 道题。
第三个样例中有两场包含 3 道题的比赛:[4,7,12] 和 [100,150,199]。
输入解题思路,AI测评打分。不知道怎么写?