PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000287. Chia kẹo cho trẻ em (Maximum Candies Allocated to K Children)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chia kẹo cho trẻ em (Maximum Candies Allocated to K Children)
Maximum Candies Allocated to K Children
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
There are candy piles of sizes . Split piles as needed, but never combine candies from different original piles. Each of children receives one pile of equal size; leftovers may be unused. Find the greatest number of candies per child, or if even one candy per child is impossible.
Input
First line: . Second line: integers .
Output
Print the maximum value, or .
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input 1
3 3
5 8 6
Output 1
5
Explanation
Each pile yields one group of size 5; size 6 yields only two groups.
Input 2
2 11
2 5
Output 2
0
Explanation
The total is 7, so 11 positive groups are impossible.