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.
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.
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
10
1 2 5 6 7 10 21 23 24 49
4
5
2 10 50 110 250
1
6
4 7 12 100 150 199
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的更多相关文章
- Codeforces 1029B. Creating the Contest 动态规划O(nlogn)解法 及 单调队列O(n)解法
题目链接:http://codeforces.com/problemset/problem/1029/B 题目大意:从数组a中选出一些数组成数组b,要求 b[i+1]<=b[i]*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 ...
- codeforce1029B B. Creating the Contest(简单dp,简单版单调栈)
B. Creating the Contest time limit per test 1 second memory limit per test 256 megabytes input stand ...
- CodeForces 377B---Preparing for the Contest(二分+贪心)
C - Preparing for the Contest Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d ...
- codeforces B. Valera and Contest 解题报告
题目链接:http://codeforces.com/problemset/problem/369/B 题目意思:给出6个整数, n, k, l, r, sall, sk ,需要找出一个满足下列条件的 ...
- Codeforces 140D - New Year Contest
140D - New Year Contest 思路:贪心+排序.罚时与时间成正比,因为在0点前做完的题都可以在0点提交.从时间短的开始做最优. 代码: #include<bits/stdc++ ...
- codeforces 659B B. Qualifying Contest(水题+sort)
题目链接: B. Qualifying Contest time limit per test 1 second memory limit per test 256 megabytes input s ...
- CodeForces - 681A A Good Contest
咳咳,从今天开始,每天做一个英语题,不论简单还是难,坚持到下学期的省赛,希望能有效果. 这题就是判断是否能成为red,如果他超越的人里面有在比赛前分数达到2400,并且在比赛后分数上升,那么他就能成为 ...
- B. Creating the Contest(水题)
直接水过 #include<iostream> #include<algorithm> using namespace std; ; int a[maxn]; int n, u ...
随机推荐
- Swiper插件
中文官网:Swiper中文网 英文:英文网 此插件功能比较强大,网页端.手机端都可以使用的插件.这里记录一下在微信h5页面里面滑动获取数据. 先下载css和js,引用到项目中 这里有6个节点,没划一个 ...
- ASP.NET中无刷新分页
上次介绍了我们代码写的刷新分页,这次就来说说无刷新分页. 这次我们是在上次的基础上改动了一些,我们都知道想要无刷新,就需要Ajax,在我们的ASP.NET中AJax是和一般处理程序配合着用的. 无刷新 ...
- REST Adapter实现SAP PI中的增强XML/JSON格式转换(转载)
SAP标准的REST adapter有着XML/JSON转换的功能,它很有用,因为一方面SAP PI/PO内部以XML格式处理数据,而另一方面,在处理REST架构风格的时候,JSON才是事实上的格式. ...
- DNS介绍与安装使用
DNS简介 DNS是互联网的一项服务.它作为将域名和IP地址相互映射的一个分布式数据库,能够使人更方便地访问互联网.DNS使用TCP和UDP的53号端口. DNS服务的基本概念 在使用DNS前需要了解 ...
- cx_freeze的安装使用
python是一个非常非常优秀的编程语言,它最大的特性就是跨平台.python程序几乎可以在所有常见的平台中进行使用,而且大部分无需修改任何代码!不过,python也有一点点小缺憾(这个是由于自身本质 ...
- python+scrapy环境搭建步骤描述
Python3(3.5.4)搭建爬虫系统步骤描述: 1.下载python安装包,路径:https://www.python.org/downloads/windows/ 选择3.5.4版本64位的安 ...
- iptables v1.3.5: multiple -d flags not allowed错误已解决
今天写了一条iptables的规则 iptables -t filter -A INPUT -s 192.168.192.0/24 -d 192.168.192.140 -p tcp -dport 2 ...
- caioj:1093: 并查集2(scy的删边问题) C++
题目描述 [题目描述] 读入一个无向图(可能含有多个连通分支),输出最多能删掉多少条边,而不改变这个图任意两点的连通性(原来连通的两个点依然连通,不连通的依然不连通). [输入格式] 第一行为图的顶点 ...
- Kings(状压DP)
Description 用字符矩阵来表示一个8x8的棋盘,'.'表示是空格,'P'表示人质,'K'表示骑士.每一步,骑士可以移动到他周围的8个方格中的任意一格.如果你移动到的格子中有人质(即'P'), ...
- 笔记-pytho-语法-yield
笔记-python-语法-yield 1. yield 1.1. yield基本使用 def fab(max): n,a,b = 0, 0, 1 while n < max: y ...