A10988 | Multi-judge Solving
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $a_{1},a_{2},...,a_{n}$ . He can solve these problems in arbitrary order. Though he can solve problem $i$ with difficulty $a_{i}$ 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.
Makes has chosen $n$ problems to solve on Decoforces with difficulties $a_{1},a_{2},...,a_{n}$ . He can solve these problems in arbitrary order. Though he can solve problem $i$ with difficulty $a_{i}$ 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.
输入格式
The first line contains two integer numbers $n$ , $k$ ( $1<=n<=10^{3}$ , $1<=k<=10^{9}$ ).
The second line contains $n$ space-separated integer numbers $a_{1},a_{2},...,a_{n}$ ( $1<=a_{i}<=10^{9}$ ).
The second line contains $n$ space-separated integer numbers $a_{1},a_{2},...,a_{n}$ ( $1<=a_{i}<=10^{9}$ ).
输出格式
Print minimum number of problems Makes should solve on other judges in order to solve all chosen problems on Decoforces.
输入输出样例
输入 #1
3 3 2 1 9
输出 #1
1
输入 #2
4 20 10 3 6 3
输出 #2
0
In the first example Makes at first solves problems 1 and 2. Then in order to solve the problem with difficulty 9, he should solve problem with difficulty no less than 5. The only available are difficulties 5 and 6 on some other judge. Solving any of these will give Makes opportunity to solve problem 3.
In the second example he can solve every problem right from the start.
In the second example he can solve every problem right from the start.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted