A14483 | Easy Scheduling
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Eonathan Eostar decided to learn the magic of multiprocessor systems. He has a full binary tree of tasks with height $h$ . In the beginning, there is only one ready task in the tree — the task in the root. At each moment of time, $p$ processes choose at most $p$ ready tasks and perform them. After that, tasks whose parents were performed become ready for the next moment of time. Once the task becomes ready, it stays ready until it is performed.
You shall calculate the smallest number of time moments the system needs to perform all the tasks.
You shall calculate the smallest number of time moments the system needs to perform all the tasks.
输入格式
The first line of the input contains the number of tests $t$ ( $1 \leq t \leq 5\cdot 10^5$ ). Each of the next $t$ lines contains the description of a test. A test is described by two integers $h$ ( $1 \leq h \leq 50$ ) and $p$ ( $1 \leq p \leq 10^4$ ) — the height of the full binary tree and the number of processes. It is guaranteed that all the tests are different.
输出格式
For each test output one integer on a separate line — the smallest number of time moments the system needs to perform all the tasks.
输入输出样例
输入 #1
3 3 1 3 2 10 6
输出 #1
7 4 173
Let us consider the second test from the sample input. There is a full binary tree of height $3$ and there are two processes. At the first moment of time, there is only one ready task, $1$ , and $p_1$ performs it. At the second moment of time, there are two ready tasks, $2$ and $3$ , and the processes perform them. At the third moment of time, there are four ready tasks, $4$ , $5$ , $6$ , and $7$ , and $p_1$ performs $6$ and $p_2$ performs $5$ . At the fourth moment of time, there are two ready tasks, $4$ and $7$ , and the processes perform them. Thus, the system spends $4$ moments of time to perform all the tasks.


C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted