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,一经查实,立即删除!

相关文章

Java—stream以及集合框架使用

1) 编写Student类&#xff0c;主要属性包括学号、姓名、性别、班级 2) 编写Score类&#xff0c;主要属性包括&#xff1a;学号、课程名、分数 3) 模拟期末考试的成绩统计应用场景&#xff0c;要求 (1) 所有学生名单及对应科目成绩已经初始化在数组中 (2) 要求输出每门课程的所有…

山东省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…

leetcode 888. 公平的糖果棒交换(set)

爱丽丝和鲍勃有不同大小的糖果棒&#xff1a;A[i] 是爱丽丝拥有的第 i 根糖果棒的大小&#xff0c;B[j] 是鲍勃拥有的第 j 根糖果棒的大小。 因为他们是朋友&#xff0c;所以他们想交换一根糖果棒&#xff0c;这样交换后&#xff0c;他们都有相同的糖果总量。&#xff08;一个…

如何使用JavaScript检查输入是否为空

by Zell Liew由Zell Liew 如何使用JavaScript检查输入是否为空 (How to check if an input is empty with JavaScript) Last week, I shared how to check if an input is empty with CSS. Today, let’s talk about the same thing, but with JavaScript.上周&#xff0c;我分…

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

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

AngularDart4.0 指南- 表单

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

(转载)分享常用的GoLang包工具

分享常用的GoLang包工具 包名 链接地址 备注 Machinery异步队列 https://github.com/RichardKnop/machinery Mqtt通信 github.com/eclipse/paho.mqtt.golang go文档http://www.eclipse.org/paho/clients/golang/ 微信开发 https://github.com/chanxuehong/wechat fasthttp包 gi…

迈向数据科学的第一步:在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…

js 触发LinkButton点击事件,执行后台方法

页面 <asp:LinkButton ID"lbtButton" runat"server" CssClass"lbtButton" Font-Underline"false" OnClick"lbtButton_Click"> js function clickButton(filePath, fileName){ __doPostBack(lbtButton, ); } 当执行该…

vue 响应式ui_如何在Vue.js中设置响应式UI搜索

vue 响应式uiAre you thinking of building something awesome with one of the popular modern frameworks out there right now, but don’t know how to get started?您是否正在考虑使用当前流行的现代框架之一来构建出色的东西&#xff0c;但不知道如何入门&#xff1f; …

兰州交通大学计算机科学与技术学院,兰州交通大学

信息与计算科学专业依托数学和计算机科学与技术两个一级学科硕士学位授予点&#xff0c;运筹学与控制论、计算机科学与技术两个省级重点学科&#xff0c;培养理工融合、学科交叉的创新性人才。自2008年以来&#xff0c;承担国家自然科学基金10余项&#xff0c;发表SCI收录杂志论…

leetcode 424. 替换后的最长重复字符(滑动窗口)

给你一个仅由大写英文字母组成的字符串&#xff0c;你可以将任意位置上的字符替换成另外的字符&#xff0c;总共可最多替换 k 次。在执行上述操作后&#xff0c;找到包含重复字母的最长子串的长度。 注意&#xff1a;字符串长度 和 k 不会超过 104。 示例 1&#xff1a; 输入…

javascript放在head和body的区别(w3c建议放在head标签中)

JavaScript脚本放在哪里 在HTML body部分中的JavaScripts会在页面加载的时候被执行。 在HTML head部分中的JavaScripts会在被调用的时候才执行。—————————————————————————— JavaScript应放在哪里 页面中的JavaScripts会在浏览器加载页面的时候被立即…

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…

策略模式下表单验证

策略模式下表单验证 class Validator {constructor(strategies) {this.cache []}add(value, rules) {if (!rules instanceof Array) throw rules should be Arrayvar self thisfor(var i 0, rule; rule rules[i];) {(function(rule) {var strategyArr rule.strategy.split…

在五分钟内学习使用Python进行类型转换

by PALAKOLLU SRI MANIKANTA通过PALAKOLLU SRI MANIKANTA 在五分钟内学习使用Python进行类型转换 (Learn typecasting in Python in five minutes) 以非常详尽的方式介绍了Python中的类型转换和类型转换的速成课程 (A crash course on Typecasting and Type conversion in Pyt…

Ajax post HTML 405,Web API Ajax POST向返回 405方法不允许_jquery_开发99编程知识库

因此&#xff0c;我有一個像這樣的jquery ajax請求&#xff1a;function createLokiAccount(someurl) {var d {"Jurisdiction":17}$.ajax({type:"POST",url:"http://myserver:111/Api/V1/Customers/CreateCustomer/",data: JSON.stringify(d),c…