编程介的小学生 2020-01-26 17:47 采纳率: 20.5%
浏览 82

Go Fishing 的计算

Problem Description
This summer vacation, FZU-ACM members get together for training in the name of dream. Some of them like fishing. One afternoon M members of them go fishing together around the lake, they bring many buckets with them and put their fish in either one of N buckets, they can only remember the number of fish they catch, and the number of fish in every bucket. When the sun went down, everyone wants to take away the part belonging to him, so they need to split the N buckets into more buckets (here we can assume the number of buckets they own is unlimited). They want to minimize the times of split. They are so tired, so ask you to help them solve their puzzle. Each time they can only split the fish in one bucket into two buckets.

Input
The input consists of several test cases. The first line of each case contains two integers N,M.(1<=N,M<8)
N representing the number of buckets they put their fish in, and M representing the number of ACM members that go fishing.
The next line contains N integers representing the number of fish in each bucket.
The next line contains M integers representing the number of fish each ACM member catch.

Output
Output the minimal times they need to split the fish.

Sample Input
2 3
1 2
1 1 1
4 3
2 4 4 3
5 5 3

Sample Output
1
1

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料