Educational Codeforces Round 25 C. Multi-judge Solving

题目链接: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;}
}

 

转载于:https://www.cnblogs.com/weimeiyuer/p/7204306.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/392014.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

山东省2021年高考成绩查询平台6,山东2021年高考成绩改为6月26日前公布

6月11日&#xff0c;山东省教育厅举行2021年第一次高考新闻发布会&#xff0c;介绍2021年高考基本情况、评卷安排、成绩公布等相关工作。山东省教育招生考试院新闻发言人、普招处处长李春光介绍&#xff0c;根据近期国家有关工作要求和强基计划招生工作需要&#xff0c;原定于6…

如何在vuejs里禁用eslint语法检查工具

eslint好是好&#xff0c;可要求很苛刻&#xff0c;对于我这种写代码很糙的媛。。。。。。 搜索的时候有的说加入 /* eslint-disabled */&#xff08;有用&#xff0c;但只是部分代码享受此待遇&#xff09; 还有说删除.eslintrc.js里包含eslint关键字的块&#xff0c;a---o---…

数据结构两个月学完_这是我作为数据科学家两年来所学到的

数据结构两个月学完It has been 2 years ever since I started my data science journey. Boy, that was one heck of a roller coaster ride!自从我开始数据科学之旅以来已经有两年了 。 男孩 &#xff0c;那可真是坐过山车&#xff01; There were many highs and lows, and…

数学哲学与科学哲学和计算机科学的能动作用,数学哲学与科学哲学和计算机科学的能动作用...

3 数学哲学与计算机科学的能动作用数学哲学对于计算机科学的影响主要表现于以下的事实&#xff1a;一些源于数学哲学(数学基础研究)的概念和理论在计算机科学的历史发展中发挥了十分重要的作用。例如&#xff0c;在此可以首先提及(一阶)谓词演算理论&#xff1a;这是由弗雷格(…

AngularDart4.0 指南- 表单

2019独角兽企业重金招聘Python工程师标准>>> 表单是商业应用程序的主流。您可以使用表单登录&#xff0c;提交帮助请求&#xff0c;下订单&#xff0c;预订航班&#xff0c;安排会议&#xff0c;并执行无数其他数据录入任务。 在开发表单时&#xff0c;创建一个数据…

迈向数据科学的第一步:在Python中支持向量回归

什么是支持向量回归&#xff1f; (What is Support Vector Regression?) Support vector regression is a special kind of regression that gives you some sort of buffer or flexibility with the error. How does it do that ? I’m going to explain it to you in simpl…

jQuery事件整合

一、jQuery事件 1、focus&#xff08;&#xff09;元素获得焦点 2、blur&#xff08;&#xff09;元素失去焦点 3、change&#xff08;&#xff09; 表单元素的值发生变化&#xff08;可用于验证用户名是否存在&#xff09; 4、click&#xff08;&#xff09; 鼠标单击 5、dbc…

tableau跨库创建并集_刮擦柏林青年旅舍,并以此建立一个Tableau全景。

tableau跨库创建并集One of the coolest things about making our personal project is the fact that we can explore topics of our own interest. On my case, I’ve had the chance to backpack around the world for more than a year between 2016–2017, and it was one…

1.0 Hadoop的介绍、搭建、环境

HADOOP背景介绍 1.1 Hadoop产生背景 HADOOP最早起源于Nutch。Nutch的设计目标是构建一个大型的全网搜索引擎&#xff0c;包括网页抓取、索引、查询等功能&#xff0c;但随着抓取网页数量的增加&#xff0c;遇到了严重的可扩展性问题——如何解决数十亿网页的存储和索引问题。20…

如何实现多维智能监控?--AI运维的实践探索【一】

作者丨吴树生&#xff1a;腾讯高级工程师&#xff0c;负责SNG大数据监控平台建设。近十年监控系统开发经验&#xff0c;具有构建基于大数据平台的海量高可用分布式监控系统研发经验。 导语&#xff1a;监控数据多维化后&#xff0c;带来新的应用场景。SNG的哈勃多维监控平台在完…

使用Python和MetaTrader在5分钟内开始构建您的交易策略

In one of my last posts, I showed how to create graphics using the Plotly library. To do this, we import data from MetaTrader in a ‘raw’ way without automation. Today, we will learn how to automate this process and plot a heatmap graph of the correlation…

请对比html与css的异同,css2与css3的区别是什么?

css主要有三个版本&#xff0c;分别是css1、css2、css3。css2使用的比较多&#xff0c;因为css1的属性比较少&#xff0c;而css3有一些老式浏览器并不支持&#xff0c;所以大家在开发的时候主要还是使用css2。CSS1提供有关字体、颜色、位置和文本属性的基本信息&#xff0c;该版…

ipywidgets_未来价值和Ipywidgets

ipywidgetsHow to use Ipywidgets to visualize future value with different interest rates.如何使用Ipywidgets可视化不同利率下的未来价值。 There are some calculations that even being easy becoming better with a visualization of his terms. Moreover, the sooner…

计算机主机后面辐射大,电脑的背面辐射大吗

众所周知&#xff0c;电子产品的辐射都比较大&#xff0c;而电脑是非常常见的电子产品&#xff0c;它也存在着一定的辐射&#xff0c;那么电脑的背面辐射大吗?下面就一起随佰佰安全网小编来了解一下吧。有资料显示&#xff0c;电脑后面的辐射比前面大&#xff0c;长期近距离在…

装饰器3--装饰器作用原理

多思考&#xff0c;多记忆&#xff01;&#xff01;&#xff01; 转载于:https://www.cnblogs.com/momo8238/p/7217345.html

用folium模块画地理图_使用Folium表示您的地理空间数据

用folium模块画地理图As a part of the Data Science community, Geospatial data is one of the most crucial kinds of data to work with. The applications are as simple as ‘Where’s my food delivery order right now?’ and as complex as ‘What is the most optim…

python创建类统计属性_轻松创建统计数据的Python包

python创建类统计属性介绍 (Introduction) Sometimes you may need a distribution figure for your slide or class. Since you are not using data, you want a quick solution.有时&#xff0c;您的幻灯片或课程可能需要一个分配图。 由于您不使用数据&#xff0c;因此需要快…

浅析STM32之usbh_def.H

【温故而知新】类似文章浅析USB HID ReportDesc (HID报告描述符) 现在将en.stm32cubef1\STM32Cube_FW_F1_V1.4.0\Middlewares\ST\STM32_USB_Host_Library\Core\Inc\usbh_def.H /********************************************************************************* file us…

C# (类型、对象、线程栈和托管堆)在运行时的相互关系

在介绍运行时的关系之前,先从一些计算机基础只是入手,如下图: 该图展示了已加载CLR的一个windows进程,该进程可能有多个线程,线程创建时会分配到1MB的栈空间.栈空间用于向方法传递实参,方法定义的局部变量也在实参上,上图的右侧展示了线程的栈内存,栈从高位内存地址向地位内存地…

2019-08-01 纪中NOIP模拟赛B组

T1 [JZOJ2642] 游戏 题目描述 Alice和Bob在玩一个游戏&#xff0c;游戏是在一个N*N的矩阵上进行的&#xff0c;每个格子上都有一个正整数。当轮到Alice/Bob时&#xff0c;他/她可以选择最后一列或最后一行&#xff0c;并将其删除&#xff0c;但必须保证选择的这一行或这一列所有…