题目链接:http://codeforces.com/contest/825/problem/C

C. Multi-judge Solving

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Makes solves problems on Decoforces and lots of other different online judges. Each problem is denoted by its difficulty — a positive integer number. Difficulties are measured the same across all the judges (the problem with difficulty d on Decoforces is as hard as the problem with difficulty d on any other judge).

Makes has chosen n problems to solve on Decoforces with difficulties a1, a2, ..., an. He can solve these problems in arbitrary order. Though he can solve problem i with difficulty ai only if he had already solved some problem with difficulty (no matter on what online judge was it).

Before starting this chosen list of problems, Makes has already solved problems with maximum difficulty k.

With given conditions it's easy to see that Makes sometimes can't solve all the chosen problems, no matter what order he chooses. So he wants to solve some problems on other judges to finish solving problems from his list.

For every positive integer y there exist some problem with difficulty y on at least one judge besides Decoforces.

Makes can solve problems on any judge at any time, it isn't necessary to do problems from the chosen list one right after another.

Makes doesn't have too much free time, so he asked you to calculate the minimum number of problems he should solve on other judges in order to solve all the chosen problems from Decoforces.

Input

The first line contains two integer numbers n, k (1 ≤ n ≤ 103, 1 ≤ k ≤ 109).

The second line contains n space-separated integer numbers a1, a2, ..., an (1 ≤ ai ≤ 109).

Output

Print minimum number of problems Makes should solve on other judges in order to solve all chosen problems on Decoforces.

Examples

Input

3 3
2 1 9

Output

1

Input

4 20
10 3 6 3

Output

 0

题目大意:

有个人想在CF上做题,每个题目有一个难度系数,现在这个人打算在CF上做n道题,这个人目前做出来的最高系数难度的题目是k,并且我们知道,对于难度系数为ai的题目,如果他已经做出来一道题d,且有2*d>=ai,他就能做出来ai这道题,否则的话,他就需要去BOJ上找一道题来做,使得他能做ai这道题。请问他至少要到BOJ上做几道题,才能全部做完n道题。

题解:

先排序,之后扫一遍,一边判断能做否,一边更新k。遇到不能做时候就去BOJ做一题ans++,然后继续更新k,输出ans...

代码:

#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 1005
int main()
{
int n,k,a[maxn];
while(cin>>n>>k)
{
int ans=0;
for(int i=0;i<n;i++) scanf("%d",&a[i]);
sort(a,a+n);
for(int i=0;i<n;i++)
{
if(a[i]<k*2) k=max(a[i],k);
else
{
while(a[i]>k*2)
{
k*=2; ans++;
}
k=max(a[i],k);
}
}
cout<<ans<<endl;
}
}

Educational Codeforces Round 25 C. Multi-judge Solving的更多相关文章

  1. Educational Codeforces Round 25 E. Minimal Labels&&hdu1258

    这两道题都需要用到拓扑排序,所以先介绍一下什么叫做拓扑排序. 这里说一下我是怎么理解的,拓扑排序实在DAG中进行的,根据图中的有向边的方向决定大小关系,具体可以下面的题目中理解其含义 Educatio ...

  2. Educational Codeforces Round 25 Five-In-a-Row(DFS)

    题目网址:http://codeforces.com/contest/825/problem/B 题目:   Alice and Bob play 5-in-a-row game. They have ...

  3. Educational Codeforces Round 25 A,B,C,D

    A:链接:http://codeforces.com/contest/825/problem/A 解题思路: 一开始以为是个进制转换后面发现是我想多了,就是统计有多少个1然后碰到0输出就行,没看清题意 ...

  4. Educational Codeforces Round 25 B. Five-In-a-Row

    题目链接:http://codeforces.com/contest/825/problem/B B. Five-In-a-Row time limit per test 1 second memor ...

  5. Educational Codeforces Round 25

    A 题意:给你一个01的字符串,0是个分界点,0把这个字符串分成(0的个数+1)个部分,分别求出这几部分1的个数.例如110011101 输出2031,100输出100,1001输出101 代码: # ...

  6. Educational Codeforces Round 25 E. Minimal Labels 拓扑排序+逆向建图

    E. Minimal Labels time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  7. Educational Codeforces Round 25 D - Suitable Replacement(贪心)

    题目大意:给你字符串s,和t,字符串s中的'?'可以用字符串t中的字符代替,要求使得最后得到的字符串s(可以将s中的字符位置两两交换,任意位置任意次数)中含有的子串t最多. 解题思路: 因为知道s中的 ...

  8. [Educational Codeforces Round 16]E. Generate a String

    [Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...

  9. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

随机推荐

  1. 768A Oath of the Night's Watch

    A. Oath of the Night's Watch time limit per test 2 seconds memory limit per test 256 megabytes input ...

  2. QTextCodec 类

    https://blog.csdn.net/qq_23948025/article/details/45500637

  3. Laravel 开启跨域请求

    项目中用到了接口,外部调用的时候老是请求不到,本地请求却没问题,查了下说是因为跨域的问题.根据网上所说解决方法如下: 1.建立中间件Cors.php命令:php artisan make:middle ...

  4. [Eclipse]Eclipse里对XML进行注释的快捷键

    eclipse中编辑java或C/C++文件时,注释的快捷键均为 "CTRL + / ",编辑xml文件时,该快捷键无效. eclipse 针对 XML 注释:CTRL + SHI ...

  5. 2018.08.17 洛谷P3135 [USACO16JAN]堡哞(前缀和处理)

    传送门 有趣的前缀和. 数据范围中的n≤200" role="presentation" style="position: relative;"> ...

  6. 数据库面试sql

    问题一:.有三张表,学生表S,课程表C,学生课程表SC 01:写出建表语句 答: create table s(id integer primary key,name varchar(20)); cr ...

  7. HDU 2546 饭卡 (01背包问题)

    题意:中文的吧,飘过~ 析:学过DP的都应该感觉到是动态规划吧,就是一个01背包问题,不同的是,这个题又加入一些新的条件,就是不满5元不能消费,过了5元即使超了也行(这个学校真不错,都可以预支),最后 ...

  8. 函数作用域和块级作用域--你不知道的JavaScript

    et和const在{}内声明都会变为外部不能访问的值,但是const声明的是常量,也不能修改 函数是 JavaScript 中最常见的作用域单元.本质上,声明在一个函数内部的变量或函数会在所处的作用域 ...

  9. [unchecked] 对作 为原始类型Hashtable的成员的put(K,V)的调用未经过检查。。。

    问题: C:\Users\Administrator\Desktop\java\SoundApplet.java:212: 警告: [unchecked] 对作为原始类型Hashtable的成员的pu ...

  10. (线段树)Balanced Lineup --POJ --3264

    链接: 对于POJ老是爆,我也是醉了, 链接等等再发吧! http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82832#problem/G 只 ...