PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000275. Giới hạn nhỏ nhất của túi bóng (Minimum Limit of Balls in a Bag)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Giới hạn nhỏ nhất của túi bóng (Minimum Limit of Balls in a Bag)
Minimum Limit of Balls in a Bag
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
There are bags with balls in bag i. One operation replaces a bag with two nonempty bags whose total ball count equals the original count. With at most operations, minimize the largest ball count of any resulting bag.
Input
The first line contains . The next line contains integers .
Output
Print the minimum possible maximum bag size.
Subtasks
- Subtask 1 (20 points): ; ; ().
- Subtask 2 (30 points): ; (); .
- Subtask 3 (50 points): ; ().
Examples
Input 1
4 4
2 4 8 2
Output 1
2
Explanation
Split the 4-ball bag once and the 8-ball bag three times into bags of size 2. Achieving size 1 would require 12 splits.