AT_arc226_b.Bin-ary Packing
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are N bags numbered 1,2,…,N. Also, for each i=0,1,…,M−1, there are Ai packages of weight 2i. There are A0+A1+⋯+AM−1 packages in total.
Every package is put into exactly one of the bags. Some bags may remain empty.
For each bag, the sum of the weights of all packages in that bag is called the weight of the bag.
Find the minimum possible value of the maximum of the weights of the N bags.
You are given T test cases; solve each of them.
有编号为 1,2,…,N 的 N 个袋子。此外,对每个 i=0,1,…,M−1,存在 Ai 个重量为 2i 的包裹。总共共有 A0+A1+⋯+AM−1 个包裹。
每个包裹恰好放入一个袋子中。某些袋子可能为空。
对于每个袋子,其中所有包裹的重量之和称为该袋子的重量。
求这 N 个袋子的重量的最大值的最小可能值。
你将收到 T 组测试数据;请分别求解每组数据。
输入格式
The input is given from Standard Input in the following format:
T
case1
case2
⋮
caseT
Each test case is given in the following format:
N M
A0 A1 … AM−1
输入从标准输入给出,格式如下:
T
case1
case2
⋮
caseT
每个测试用例的格式如下:
N M
A0 A1 … AM−1
输出格式
Output T lines.
The i-th line should contain the minimum possible value of the maximum of the weights of the bags for the i-th test case.
输出 T 行。
第 i 行应包含第 i 个测试用例中,各袋子重量的最大值的最小可能值。
输入输出样例
输入#1
4 2 3 3 2 1 1000000 1 0 1 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 188075 10 858153 791486 630853 157728 813993 50047 286602 459270 597406 907405
输出#1
6 0 549755813888 3805
说明/提示
Sample 1 Explanation:
In the first test case, there are 3,2,1 packages of weight 1,2,4, respectively.
For example, let the weights of the packages put into bags 1,2 be (4,1,1),(2,2,1), respectively. Then, the weights of bags 1,2 are 6,5, respectively, and the maximum of these is 6.
It is impossible to make the maximum of the weights of the bags 5 or less.
Constraints
- 1≤T≤105
- 1≤N≤106
- 1≤M≤40
- 0≤Ai≤106
- The sum of M over all test cases is at most 2×105.
- All input values are integers.
样例 1 解释:
在第一个测试用例中,重量分别为 1,2,4 的包裹数量依次为 3,2,1。
例如,将重量为 (4,1,1) 的包裹放入背包 1,将重量为 (2,2,1) 的包裹放入背包 2。此时,背包 1 和背包 2 的总重量分别为 6 和 5,其最大值为 6。
无法使所有背包的总重量最大值不超过 5。
约束条件
- 1≤T≤105
- 1≤N≤106
- 1≤M≤40
- 0≤Ai≤106
- 所有测试用例中 M 的总和不超过 2×105。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?